Notice
Recent Posts
Recent Comments
Link
Β«   2026/05   Β»
일 μ›” ν™” 수 λͺ© 금 ν† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Tags
more
Archives
Today
Total
관리 메뉴

η„‘μ œ

μ½”λ“œ 해석_0327_product/flex/position/relative/absolute/wrap/overflow/hidden/opacity/transition/z-index/transform/translate λ³Έλ¬Έ

<401>

μ½”λ“œ 해석_0327_product/flex/position/relative/absolute/wrap/overflow/hidden/opacity/transition/z-index/transform/translate

yo-u-loo 2026. 3. 27. 17:32

 

πŸ‘‡πŸ» β€ŠHTML

<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>CSS3 μ• λ‹ˆλ©”μ΄μ…˜</title>
  <link rel="stylesheet" href="css/product.css">
</head>
<body>
  <div id="container">
    <h1>μ‹ μƒν’ˆ λͺ©λ‘</h1>
    <ul class="prod-list">
      <li>
        <img src="images/prod1.jpg">
        <div class="caption">
          <h2>μƒν’ˆ 1</h2>
          <p>가격 : 12,345원</p>
        </div>
      </li>
      <li>
        <img src="images/prod2.jpg">
        <div class="caption">
          <h2>μƒν’ˆ 2</h2>
          <p>μƒν’ˆ 2 μ„€λͺ… ν…μŠ€νŠΈ</p>
          <p>가격 : 12,345원</p>
        </div>
      </li>
      <li>
        <img src="images/prod3.jpg">
        <div class="caption">
          <h2>μƒν’ˆ 3</h2>
          <p>μƒν’ˆ 3 μ„€λͺ… ν…μŠ€νŠΈ</p>
          <p>가격 : 12,345원</p>
        </div>
      </li>
    </ul>
  </div>
</body>
</html>

πŸ‘†πŸ»β€Š 14/results/product.html

πŸ‘‡πŸ»β€Š CSS

/* 전체 μ»¨ν…Œμ΄λ„ˆ μ˜μ—­ μ„€μ • */
#container {
  max-width: 1000px;
  margin: 20px auto;
  width: 100%;
}

/* 제λͺ© 쀑앙 μ •λ ¬ */
h1 {
  text-align: center; /* ν…μŠ€νŠΈ 쀑앙 μ •λ ¬ */
}

/* μƒν’ˆ 리슀트 μŠ€νƒ€μΌ */
.prod-list {
  list-style: none; /* 마컀 λͺ¨μ–‘ 제거 */
  padding: 0;
  display: flex; /* 블둝 μš”μ†Œλ‘œ λ³€κ²½ */
  flex-wrap: wrap; /* ν•­λͺ©μ΄ μ»¨ν…Œμ΄λ„ˆ λ„ˆλΉ„λ₯Ό μ΄ˆκ³Όν•˜λ©΄ λ‹€μŒ μ€„λ‘œ 이동 */
  justify-content: space-around; /* ν•­λͺ© μ‚¬μ΄μ˜ 여백을 κ· λ“±ν•˜κ²Œ λΆ„λ°° */
}

/* 각 μƒν’ˆ ν•­λͺ© μŠ€νƒ€μΌ */
.prod-list li {
  padding: 0;
  margin: 10px;
  overflow: hidden; /* μžμ‹ μš”μ†Œκ°€ μ˜μ—­μ„ λ„˜μ–΄κ°€λ©΄ μˆ¨κΉ€ */
  flex-basis: calc(33.333% - 20px); /* ν•œ 쀄에 3개의 ν•­λͺ©, λ§ˆμ§„ 20px κ³ λ € */
  position: relative; /* μ ˆλŒ€ μœ„μΉ˜ μ§€μ • */
}

/* μƒν’ˆ 이미지 μŠ€νƒ€μΌ */
.prod-list img {
  width: 100%; /* 이미지가 li ν•­λͺ© λ„ˆλΉ„μ— 맞게 μ‘°μ • */
  height: auto; /* 이미지 λΉ„μœ¨ μœ μ§€ */
  z-index: 5; /* μΊ‘μ…˜λ³΄λ‹€ μ•„λž˜μ— ν‘œμ‹œ */
}

/* μƒν’ˆ μΊ‘μ…˜(μ„€λͺ…) μŠ€νƒ€μΌ */
.prod-list .caption {
  position: absolute; /* li κΈ°μ€€ μ ˆλŒ€ μœ„μΉ˜ */
  top: 200px;
  width: 100%; /* li λ„ˆλΉ„μ— 맞좀 */
  height: 200px;
  padding-top: 20px;
  background: rgba(0,0,0,0.6);
  opacity: 0; /* μ²˜μŒμ—λŠ” 보이지 μ•ŠμŒ */
  transition: all 0.6s ease-in-out; /* ν˜Έλ²„ μ‹œ μ „μ²΄μ μœΌλ‘œ 0.6μ΄ˆλ™μ•ˆ 느리게 μ‹œμž‘ → λΉ λ₯΄κ²Œ μ§„ν–‰ → 느리게 끝남 */
  z-index: 10; /* 이미지 μœ„μ— ν‘œμ‹œ */
}

/* li ν•­λͺ©μ— 마우슀λ₯Ό 올리면 μΊ‘μ…˜ μ• λ‹ˆλ©”μ΄μ…˜ 적용 */
.prod-list li:hover .caption {
  opacity: 1; /* 마우슀 올리면 보이도둝 λ³€κ²½ */
  transform: translateY(-200px); /* μœ„λ‘œ 이동 */
}

/* μΊ‘μ…˜ λ‚΄λΆ€ 제λͺ©κ³Ό 문단 μŠ€νƒ€μΌ */
.prod-list .caption h2, .prod-list .caption p {
  color: #fff;
  text-align: center; /* 쀑앙 μ •λ ¬ */
}
}

 

πŸ‘†πŸ»β€Š 14/results/product.css

http://127.0.0.1:5500/doit-hcj-new-main/14/results/product.html

 

#html #div #ul #li #img #src #class

#css #text-align #display #flex #flex-wrap #wrap # justify-content #space-around #overflow #hidden #flex-basis #calc #position #relative #z-index #absolute #opacity #transition #ease-in-out #:hover #transform #translateY