• 카테고리

    질문 & 답변
  • 세부 분야

    웹 개발

  • 해결 여부

    미해결

display:flex하면 h태그랑 p태그가 같은 줄로 붙어버려요

21.11.09 00:45 작성 조회수 349

1

강의 2:00부분에서  display:flex 이거 적용하면 선생님꺼랑 다르게 되요

.hexagon .caption {
  position: absolute;
  width: inherit;
  height: inherit;
  color: #fff;
  transition: 0.5s;
  display: flex;
}

 

 

 

 

이런식으로 h태그랑 p태그가 나란히 배치되어 버려요.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="frame">
    <div class="hexagon">
      <div class="shape">
        <div class="caption">
          <h2>Photographer</h2>
          <p>
            As in other arts, the definitions of amateur and professional are not entirely categorical.
          </p>
        </div>
        <img src="images/artist-01.jpg">
      </div>
    </div>
    <div class="hexagon">
      <div class="shape">
        <div class="caption">
          <h2>Musician</h2>
          <p>
            A composer is a musician who creates musical compositions.
          </p>
        </div>
        <img src="images/artist-02.jpg">
      </div>
    </div>
    <div class="hexagon">
      <div class="shape">
        <div class="caption">
          <h2>Sculptor</h2>
          <p>
            Sculpture is the branch of the visual arts that operates in three dimensions..
          </p>
        </div>
        <img src="images/artist-03.jpg">
      </div>
    </div>
  </div>
</body>
</html>
 
 
/* Google Web Font */
@import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500&display=swap');

*{
  box-sizing: border-box;
}

body {
  font-family: 'Montserrat', sans-serif;
  margin: 0;
  padding: 0;
  color: #333;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
 
}

a{
  text-decoration: none;
  color: inherit;
}


.frame {
  display: flex;
  gap: 40px;
}
.hexagon {
  width: 400px;
  height: 450px;
  position: relative;
}
.shape {
  clip-path: polygon(50% 0, 100% 30%, 100% 70%, 50% 100%, 0 70%, 0 30%);
  width: inherit;
  height: inherit;
  position: absolute;
}
.shape img {
  width: inherit;
  height: inherit;
  object-fit: cover;
  object-position: right;
}
.hexagon .caption {
  position: absolute;
  width: inherit;
  height: inherit;
  color: #fff;
  transition: 0.5s;
  display: flex;
}
뭘 잘못한걸까요 ㅠㅠ
 

답변 1

답변을 작성해보세요.

0

이 부분은 영상이 잘못된 부분 때문에 그렇습니다.

pororo556 님께서 잘못하신게 아닙니다.

CSS 호버이펙트 - 클립패쓰(Clip-path) 이미지 오버레이(1) 영상의 5분 29초에 .caption 밑에 h2와 p태그를 부모요소 div로 감싸주는 부분 설명이 짤리고 진행되서 애먹으신거에요. 완성본 다운로드해서 코드 보시면 .caption 밑에 h2와 p태그를 부모요소 div로 감싸져 있습니다.

곧, 아래 코드처럼 해주셔야 영상처럼 결과물을 만드실 수 있어요.

<div class="caption">

       <div>

            <h2>Photographer</h2>

            <p>

              As in other arts, the definitions of amateur..........

            </p>

      </div>

</div>

이건 저의 실수이니 죄송합니다.

아래 이미지를 보시면  .caption 밑에 h2와 p태그를 부모요소 div로 감싸지 않고 같은 결과를 만드는 방법도 적어 놓았습니다. 

공부하시는데 혼란을 드려서 죄송합니다.ㅠㅠ