๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
HTML5 & CSS3

[HTML5 & CSS3] ์‹ค์Šต - ๊ณ ์–‘์ด ๋ถ„์–‘ ํŽ˜์ด์ง€ (์‹ฌํ™”)

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2021. 2. 15.
๋ฐ˜์‘ํ˜•

๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ฆฌ๋ฉด ์•„๋ž˜์—์„œ ์œ„๋กœ ์˜ฌ๋ผ์˜ค๋ฉด์„œ ์ €๋ ‡๊ฒŒ ๊ธ€์”จ๊ฐ€ ๋œจ๊ฒŒ ๋งŒ๋“ค๊ฒƒ

 

<์†Œ์Šค>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>๊ณ ์–‘์ด ๋ถ„์–‘</title>
<style>
   * {
      margin: 0; /* ์™ธ๋ถ€ ์—ฌ๋ฐฑ */
      padding: 0; /* ํ…Œ๋‘๋ฆฌ์™€ ๋‚ด์šฉ ์‚ฌ์ด์˜ ์—ฌ๋ฐฑ */
      box-sizing: border-box;
   }
   #container {
      width: 100%; /* ๋„ˆ๋น„ */
   }
   header {
      width: 100%; /* ๋„ˆ๋น„ */
      height: 80px; /* ๋†’์ด */
      margin: 0; /* ์™ธ๋ถ€ ์—ฌ๋ฐฑ */
   }
   a {
      text-decoration: none; /* ๊ธ€์ž ๊พธ๋ฐˆ */
   } 
   nav {
      height: 50px; /* ๋†’์ด */
      background:skyblue; /* ๋ฐฐ๊ฒฝ ์ƒ‰ */
   }
   #main-nav {
      list-style: none;
      margin-bottom: 10px;
      padding: 10px; /* ํ…Œ๋‘๋ฆฌ์™€ ๋‚ด์šฉ ์‚ฌ์ด์˜ ์—ฌ๋ฐฑ */
      text-align: center;
   }
   #main-nav li {
      display: inline-block;    
      color: #fff;
      font-family: "๋ง‘์€ ๊ณ ๋”•", ๋‹์›€;
      font-size: 0.9em;
      margin: 5px 15px; /* ์™ธ๋ถ€ ์—ฌ๋ฐฑ */
   }
   nav a:link, a:visited {
      color: #fff;
   }
   nav > ul > li {
      width: 15%; /* ๋„ˆ๋น„ */
      height: 40px; /* ๋†’์ด */
      margin-top: 30px; /* ์š”์†Œ ์ฃผ๋ณ€ ์—ฌ๋ฐฑ */
      position:relative; /* ์›๋ž˜ ์ž์‹ ์ด ์žˆ์–ด์•ผ๋  ์œ„์น˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ฐฐ์น˜ */
      float:center; /* ์ •๋ ฌ */
   }
   nav > ul > li > a {
      display: block; /* ํ˜•ํƒœ */
      width: 25%px; /* ๋„ˆ๋น„ */
      height: 40px; /* ๋†’์ด */
      text-align: center; /* ๊ฐ€์šด๋ฐ ์ •๋ ฌ */
      line-height: 40px; /* ์ค„ ๊ฐ„๊ฒฉ */
      font-size: 18px; /* ๊ธ€์ž ํฌ๊ธฐ */
      color:black /* ๊ธ€์ž ์ƒ‰ */
   }
   nav > ul > li > a:hover {
      background-color: gray; 
      color: floralwhite;
   }  
   #menus {
      width: 100%; /* ๋„ˆ๋น„ */      
   }
   #menus > div {
      height: 400px; /* ๋†’์ด */
      margin-bottom: 10px; /* ์š”์†Œ ์ฃผ๋ณ€ ์—ฌ๋ฐฑ */
      position: relative;
   }
   #menu1, #menu2, #menu3, #menu4, #menu5 {
      width: 100%; /* ๋„ˆ๋น„ */
   }
   #menus .caption h4 {
      position: absolute;
      padding: 5px; /* ํ…Œ๋‘๋ฆฌ์™€ ๋‚ด์šฉ ์‚ฌ์ด์˜ ์—ฌ๋ฐฑ */
      font-size: 20px;
      color:white;
      text-shadow: 3px 3px 5px black;
      left: 35%;
      bottom: 150px;
   }
   #menu1 {
      background:url("cat1.png") no-repeat center;
      background-size: cover;
   }
   #menu2 {
      background:url("cat2.png") no-repeat center;
      background-size: cover;
   }
   #menu3 {
      background:url("cat3.png") no-repeat center;
      background-size: cover;
   }
   #menu4 {
      background:url("cat4.png") no-repeat center;
      background-size: cover;
   }
   #menu5 {
      background:url("cat5.png") no-repeat center;
      background-size: cover;
   }
   footer {
      width: 100%; /* ๋„ˆ๋น„ */
      background:#373737; /* ๋ฐฐ๊ฒฝ ์ƒ‰ */
      height: 200px; /* ๋†’์ด */
   }
   footer p {
      font-size: 1.2em; /* ๊ธ€์ž ํฌ๊ธฐ */
      color:#eee; /* ์ƒ‰๊น” */
      text-align: center; /* ๊ฐ€์šด๋ฐ ์ •๋ ฌ */
      line-height: 200px; /* ์ค„ ๊ฐ„๊ฒฉ */
   }
โ€‹
   @media all and (min-width:768px) {
      #menus {
         display: flex; /* ํ”Œ๋ ‰์„œ๋ธ” ๋ฐ•์Šค ๋ ˆ์ด์•„์›ƒ ์ ์šฉ */
         -ms-flex-wrap: wrap;
         -webkit-flex-wrap: wrap;
         flex-wrap: wrap; /* ์—ฌ๋Ÿฌ ์ค„์— ๊ฑธ์ณ ํ‘œ์‹œ */
         justify-content: space-between; /* ํ™”๋ฉด ์–‘์ชฝ์— ๋ฐ”์ง ๋ถ™์ด๊ธฐ  */
      }
      #menu1, #menu2, #menu3, #menu4 {
         width: 49%; /* ๋„ˆ๋น„ */
      }
      #menu5 {
         width: 100%; /* ๋„ˆ๋น„ */
      }
   }
โ€‹
   @media all and (min-width:992px) {
      #menu1, #menu2, #menu3, #menu4, #menu5 {
         width: 33%; /* ๋„ˆ๋น„ */
      } 
      #menu5 {
         margin-left: 0.5%; /* ์š”์†Œ ์ฃผ๋ณ€ ์—ฌ๋ฐฑ */
         -ms-flex: 2 2 0;
         -webkit-flex: 2 2 0;
         flex: 2 2 0;
      }
   }
โ€‹
   .button {
      cursor: pointer;
      background: #000; /* ๋ฐฐ๊ฒฝ */
      text-decoration: none; /* ๊ธ€์ž ๊พธ๋ฐˆ */
      color: #666; /* ์ƒ‰๊น” */
   }
โ€‹
   .curl-top-left {
      display: inline-block; /* ํ˜•ํƒœ */
      position: relative; /* ์›๋ž˜ ์ž์‹ ์ด ์žˆ์–ด์•ผ๋  ์œ„์น˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ฐฐ์น˜ */
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
      transform: translateZ(0);
      box-shadow: 0 0 1px rgba(0, 0, 0, 0);
   }
โ€‹
   .curl-top-left:before {
      pointer-events: none;
      position: absolute;
      content: '';
      height: 0; /* ๋†’์ด */
      width: 0; /* ๋„ˆ๋น„ */
      top: 0;
      left: 0;
      background: white; /* ๋ฐฐ๊ฒฝ */
   /* IE9 */
      background: linear-gradient(135deg, white 45%, #aaa 50%, #ccc 56%, white 80%);
      filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#ffffff', endColorstr='#000000');
   /*For IE7-8-9*/
      z-index: 1000;
      box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4); /* ๋ฐ•์Šค ๊ทธ๋ฆผ์ž */
      transition-duration: 0.3s;
      transition-property: width height;
   }
โ€‹
   .curl-top-left:hover:before {
      width: 16px; /* ๋„ˆ๋น„ */
      height: 16px; /* ๋†’์ด */
   }
โ€‹
   #menu1:hover .caption, #menu2:hover .caption, #menu3:hover .caption, #menu4:hover .caption, #menu5:hover .caption {
      opacity: 1;
      -moz-transform: translateY(-50px);
      -ms-transform: translateY(-50px);
      -o-transform: translateY(-50px);
      -webkit-transform: translateY(-50px);
      transform: translateY(-50px);
      margin:0;
      padding:0;
      float:left;
      z-index:5;
   }  
โ€‹
   #menu1 .caption, #menu2 .caption, #menu3 .caption, #menu4 .caption {
      position:absolute;
      width: 635px; /* ๋ฐ•์Šค ๋„ˆ๋น„ */
      height:400px; /* ๋ฐ•์Šค ๋†’์ด */
      padding-top: 20px;
      background: rgba(0,0,0,0.6);
      opacity: 0;
      -moz-transition: all 0.2s ease-in-out;
      -o-transition:all 0.2s ease-in-out;
      -webkit-transition: all 0.2s ease-in-out;
      transition: all 0.2s ease-in-out;
      z-index: 10;
   }       
โ€‹
   #menu5 .caption {
      position:absolute;
      width:1300px; /* ๋ฐ•์Šค ๋„ˆ๋น„ */
      height:400px; /* ๋ฐ•์Šค ๋†’์ด */
      background: rgba(0,0,0,0.6);
      opacity: 0;
      -moz-transition: all 0.2s ease-in-out;
      -o-transition:all 0.2s ease-in-out;
      -webkit-transition: all 0.2s ease-in-out;
      transition: all 0.2s ease-in-out;
      z-index: 10;
   }       
</style>
</head>
<body>
<div id="container">
<header>
   <nav>
      <ul id="main-nav">
         <li><a href='#'><b>์‚ฌ์ดํŠธ ์†Œ๊ฐœ</b></a></li>          
         <li><a href='catinfo.html'><h1>๊ณ ์–‘์ด ๋ถ„์–‘</h1></a></li>
         <li><a href='catshow.html'><b>๊ณ ์–‘์ด ์ž๋ž‘</b></a></li>
         <li><a href='#'><b>๊ณ ๊ฐ์„ผํ„ฐ</b></a></li>
      </ul>
   </nav>
</header>
<section id="menus">
<div id="menu1">
   <div class="caption">
      <h4>
         ํ’ˆ์ข… : ๋Ÿฌ์‹œ์•ˆ๋ธ”๋ฃจ<br>
         ์„ฑ๋ณ„ : ๋‚จ<br>
         ๋‚˜์ด : 1์‚ด<br>
         ๋ถ„์–‘๊ฐ€ : 100๋งŒ์›<br>
      </h4>
   </div>       
</div>
<div id="menu2">
   <div class="caption">
      <h4>
         ํ’ˆ์ข… : ์•„๋ฉ”๋ฆฌ์นธ ์ˆํ—ค์–ด<br>
         ์„ฑ๋ณ„ : ์—ฌ<br>
         ๋‚˜์ด : 3๊ฐœ์›”<br>
         ๋ถ„์–‘๊ฐ€ : 50๋งŒ์›<br>
      </h4>
   </div>       
</div>
<div id="menu3">
   <div class="caption">
      <h4>
         ํ’ˆ์ข… : ์ฝ”๋ฆฌ์•ˆ ์ˆํ—ค์–ด<br>
         ์„ฑ๋ณ„ : ๋‚จ<br>
         ๋‚˜์ด : 2์‚ด<br>
         ๋ถ„์–‘๊ฐ€ : 5๋งŒ์›<br>
      </h4>
   </div>
</div>
<div id="menu4">
   <div class="caption">
      <h4>
         ํ’ˆ์ข… : ํŽ˜๋ฅด์‹œ์•ˆ๊ณ ์–‘์ด<br>
         ์„ฑ๋ณ„ : ๋‚จ<br>
         ๋‚˜์ด : 1์‚ด<br>
         ๋ถ„์–‘๊ฐ€ : 1000๋งŒ์›<br>
      </h4>
   </div>
</div>
<div id="menu5">
   <div class="caption">
      <h4>
         ํ’ˆ์ข… : ๋ธŒ๋ฆฌํ‹ฐ์‰ฌ์ˆํ—ค์–ด<br>
         ์„ฑ๋ณ„ : ๋‚จ<br>
         ๋‚˜์ด : 1์‚ด<br>
         ๋ถ„์–‘๊ฐ€ : 20๋งŒ์›<br>
      </h4>
   </div>
</div>
</section>
</div>
</body>
</html>

caption์œผ๋กœ ๊ธ€์ž๋ฅผ ๋ฌถ์–ด์„œ ๊ด€๋ฆฌํ–ˆ๋‹ค.

id์—๋Š” #๋ฅผ, class์—๋Š” .๋ฅผ ์“ฐ๋Š”๊ฒŒ ์•„์ง ํ—ท๊ฐˆ๋ ค์„œ ์กฐ๊ธˆ ํ—ค๋งธ๋‹ค.

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€