🍎 듀어가기에 μ•žμ„œ

이 글은 λͺ¨λ˜ 웹을 μœ„ν•œ HTML5+CSS3 바이블을 κ³΅λΆ€ν•˜λ©° κΈ°μ–΅ν•΄λ‘˜ λ‚΄μš©λ“€μ„ κ°„λ‹¨ν•˜κ²Œ κΈ°λ‘ν•œ κΈ€μž…λ‹ˆλ‹€.
책에 λŒ€ν•œ μžμ„Έν•œ 사항은 링크λ₯Ό μ°Έκ³ ν•΄μ£Όμ„Έμš”. πŸ‘

πŸ“– 1. μ›Ή νŽ˜μ΄μ§€ λ ˆμ΄μ•„μ›ƒ

λ ˆμ΄μ•„μ›ƒ κ΄€λ ¨ μ±•ν„°μ˜ 경우 μ½”λ“œλ₯Ό μ­‰ λ‚˜μ—΄ν•˜κ³  μ£Όμ„μœΌλ‘œ λ„μ›€λ˜λŠ” νŒλ“€(🌟둜 ν‘œμ‹œν•΄λ‘κ² μŠ΅λ‹ˆλ‹€.)을 κΈ°λ‘ν•˜λ € ν•©λ‹ˆλ‹€.
μ½”λ“œ 원본은 λ§ν¬μ—μ„œ λ°›μœΌμ‹€ 수 μžˆμŠ΅λ‹ˆλ‹€.

<!DOCTYPE html>
<html>
  <head>
    <title>Chapter_5</title>
    <!-- 🌟 μ΄ˆκΈ°ν™” : ν•„μˆ˜λŠ” μ•„λ‹ˆμ§€λ§Œ, 보톡 전체 μ„ νƒμž(*)λ₯Ό 톡해 μ•„λž˜μ™€ 같은 κ°’μœΌλ‘œ μ΄ˆκΈ°ν™” ν›„ μŠ€νƒ€μΌλ§μ„ μ§„ν–‰ν•©λ‹ˆλ‹€. -->
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        font-family: 'Times New Roman', serif;
      }
      li {
        list-style: none;
      }
      a {
        text-decoration: none;
      }
      img {
        border: 0;
      }
    </style>
    <!-- 헀더 -->
    <style>
      #main_header {
        /* 🌟 쀑앙 μ •λ ¬ : λ‹€μŒκ³Ό 같은 λ°©λ²•μœΌλ‘œ 자주 쀑앙 μ •λ ¬ν•΄μ€λ‹ˆλ‹€.*/
        width: 960px;
        margin: 0 auto;

        /* 🌟 μ ˆλŒ€ μ’Œν‘œ : μ•„λž˜ μžμ† νƒœκ·Έμ— absoluteλ₯Ό μ μš©ν•˜κΈ°μ— λΆ€λͺ¨ νƒœκ·Έμ— relativeλ₯Ό μ μš©ν•©λ‹ˆλ‹€.
        λ˜ν•œ 곡간 확보λ₯Ό μœ„ν•΄ height값을 μ§€μ •ν•΄μ€λ‹ˆλ‹€. */
        height: 160px;
        position: relative;
      }
      #main_header > #title {
        position: absolute;
        left: 20px;
        top: 30px;
      }
      #main_header > #main_gnb {
        position: absolute;
        right: 0;
        top: 0;
      }
      #main_header > #main_lnb {
        position: absolute;
        right: 0;
        bottom: 10px;
      }
    </style>
    <!-- 타이틀 -->
    <style>
      #title {
        font-family: 'Coiny', cursive;
      }
    </style>
    <!-- 메뉴(1) -->
    <style>
      /* 🌟 li νƒœκ·Έλ“€μ„ μˆ˜ν‰μœΌλ‘œ λ§Œλ“€κΈ° μœ„ν•΄ float: leftλ₯Ό μ μš©ν•˜κ³  κ·Έ λΆ€λͺ¨ νƒœκ·Έμ— overflow: hidden 처리λ₯Ό ν•΄μ€λ‹ˆλ‹€. */
      #main_gnb > ul {
        overflow: hidden;
      }
      #main_gnb > ul > li {
        float: left;
      }
      #main_gnb > ul > li > a {
        display: block;
        padding: 2px 10px;
        border: 1px solid black;
      }
      #main_gnb > ul > li > a:hover {
        background: black;
        color: white;
      }
      #main_gnb > ul > li:first-child > a {
        border-radius: 10px 0 0 10px;
      }
      #main_gnb > ul > li:last-child > a {
        border-radius: 0 10px 10px 0;
      }
    </style>
    <!-- 메뉴(2) -->
    <style>
      #main_lnb > ul {
        overflow: hidden;
      }
      #main_lnb > ul > li {
        float: left;
      }
      #main_lnb > ul > li > a {
        display: block;
        padding: 10px 20px;
        border: 1px solid black;
      }
      #main_lnb > ul > li > a:hover {
        background: black;
        color: white;
      }
      #main_lnb > ul > li:first-child > a {
        border-radius: 10px 0 0 10px;
      }
      #main_lnb > ul > li:last-child > a {
        border-radius: 0 10px 10px 0;
      }
    </style>
    <!-- μ½˜ν…μΈ  -->
    <style>
      #content {
        /* 쀑앙 μ •λ ¬ */
        width: 960px;
        margin: 0 auto;

        /* 🌟 μˆ˜ν‰ λ ˆμ΄μ•„μ›ƒ ꡬ성: μžμ† νƒœκ·Έμ— float을 μ μš©ν•˜κ²Œ 되면 총 λ„ˆλΉ„(960px)μ—μ„œ 각각의 λ„ˆλΉ„(750px, 200px)의 합에 λŒ€ν•΄μ„œ 10px이 λ‚¨κ²Œ λ©λ‹ˆλ‹€.
        이 10px을 κ°„κ²©μœΌλ‘œ 두고 #main_sectionκ³Ό #main_aside의 곡간이 λΆ„λ¦¬λ©λ‹ˆλ‹€.(즉, μžμ†μ˜ λ„ˆλΉ„λ₯Ό 지정해주면 μ•Œμ•„μ„œ 남은 κ°’μœΌλ‘œ 간격이 μƒκΉλ‹ˆλ‹€.) */
        overflow: hidden;
      }
      #content > #main_section {
        width: 750px;
        float: left;
      }
      #content > #main_aside {
        width: 200px;
        float: right;
      }
    </style>
    <!-- λ³Έλ¬Έ -->
    <style>
      #main_section > article.main_article {
        margin-bottom: 10px;
        padding: 20px;
        border: 1px solid black;
      }
    </style>
    <!-- μ‚¬μ΄λ“œ -->
    <style>
      /* 🌟 첫 번째 νƒ­: input의 check μ•„μ΄μ½˜ μžμ²΄λŠ” μˆ¨κΉλ‹ˆλ‹€. input이 μ²΄ν¬λ˜μ§€ μ•Šμ•˜μ„ λ•ŒλŠ” μ•ˆλ³΄μ΄κ²Œ ν•˜κ³ , 체크가 되면 보이게 ν•©λ‹ˆλ‹€. */
      input:nth-of-type(1) {
        display: none;
      }
      input:nth-of-type(1) ~ div:nth-of-type(1) {
        display: none;
      }
      input:nth-of-type(1):checked ~ div:nth-of-type(1) {
        display: block;
      }

      /* 🌟 두 번째 νƒ­: 첫 λ°΄μ§Έ 텝과 λ§ˆμ°¬κ°€μ§€μž…λ‹ˆλ‹€. */
      input:nth-of-type(2) {
        display: none;
      }
      input:nth-of-type(2) ~ div:nth-of-type(2) {
        display: none;
      }
      input:nth-of-type(2):checked ~ div:nth-of-type(2) {
        display: block;
      }

      /* νƒ­ λͺ¨μ–‘ ꡬ성 */
      section.buttons {
        overflow: hidden;
      }
      section.buttons > label {
        /* μˆ˜ν‰ μ •λ ¬ */
        display: block;
        float: left;

        /* 크기 및 κΈ€μž μœ„μΉ˜ 지정*/
        width: 100px;
        height: 30px;
        line-height: 30px;
        text-align: center;

        /* ν…Œλ‘λ¦¬ 지정 */
        box-sizing: border-box;
        border: 1px solid black;

        /* 색상 지정*/
        background: black;
        color: white;
      }
      input:nth-of-type(1):checked ~ section.buttons > label:nth-of-type(1) {
        background: white;
        color: black;
      }
      input:nth-of-type(2):checked ~ section.buttons > label:nth-of-type(2) {
        background: white;
        color: black;
      }
    </style>
    <!-- λͺ©λ‘ -->
    <style>
      .item {
        overflow: hidden;
        padding: 10px;
        border: 1px solid black;
        border-top: none;
      }
      .thumbnail {
        float: left;
      }
      .description {
        float: left;
        margin-left: 10px;
      }
      .description > strong {
        display: block;
        width: 120px;
        white-space: nowrap; /* 🌟 λ°•μŠ€ λ‚΄μ˜ κΈ€μžκ°€ 더 κΈΈμ–΄μ„œ ν˜•νƒœκ°€ 깨질 λ•Œ μ‚¬μš©ν•©λ‹ˆλ‹€. */
        overflow: hidden; /* 🌟 μ‚¬μš©ν•˜κ²Œ 되면 'jayden is good!'κ³Ό 같은 κΈ€μžκ°€ 'jayden is...' 둜 λ°•μŠ€ 크기에 맞게 μƒλž΅λ©λ‹ˆλ‹€. */
        text-overflow: ellipsis; /* 🌟 이 3가지 속성이 ν•¨κ»˜ μ μš©λ˜λ―€λ‘œ ν†΅μ§Έλ‘œ μΈμ§€ν•˜κ³  μ°Ύμ•„μ„œ λ³΅λΆ™ν•˜μ—¬ μ‚¬μš©ν•˜λŠ” 게 μ’‹μŠ΅λ‹ˆλ‹€. ✍️ */
      }
    </style>
    <!-- ν‘Έν„° -->
    <style>
      #main_footer {
        /* 쀑앙 μ •λ ¬ */
        width: 960px;
        margin: 0 auto;
        margin-bottom: 10px;

        /* ν…Œλ‘λ¦¬ */
        box-sizing: border-box;
        padding: 10px;
        border: 1px solid black;

        /* κΈ€μž μ •λ ¬ */
        text-align: center;
      }
    </style>
  </head>
  <body>
    <header id="main_header">
      <div id="title">
        <h1>Rint Development</h1>
        <h2>HTML5 + CSS3 Basic</h2>
      </div>
      <nav id="main_gnb">
        <ul>
          <li><a href="#">Web</a></li>
          <li><a href="#">Mobile</a></li>
          <li><a href="#">Game</a></li>
          <li><a href="#">Simulation</a></li>
          <li><a href="#">Data</a></li>
        </ul>
      </nav>
      <nav id="main_lnb">
        <ul>
          <li><a href="#">HTML5</a></li>
          <li><a href="#">CSS3</a></li>
          <li><a href="#">JavaScript</a></li>
          <li><a href="#">jQuery</a></li>
          <li><a href="#">Node.js</a></li>
        </ul>
      </nav>
    </header>
    <div id="content">
      <section id="main_section">
        <article class="main_article">
          <h1>Main Article</h1>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur in magna libero. Sed
            nec pharetra nunc. Proin eget magna id ipsum eleifend cursus sit amet nec lectus. Nunc
            quis lacus magna. Aliquam blandit, sapien ut viverra fermentum, elit tortor ornare nisi,
            in luctus sem massa pulvinar turpis. Cras tincidunt dictum urna ut ultricies. Nullam
            diam nibh, pellentesque non laoreet ut, bibendum nec mauris. Maecenas pulvinar porttitor
            laoreet. Vivamus bibendum purus nisl, eget aliquam lectus. Maecenas justo libero,
            euismod sit amet suscipit eu, vulputate eget neque. Aliquam quam est, blandit nec
            iaculis non, suscipit vel nunc. Proin et odio aliquam erat pharetra accumsan et quis
            neque. Vivamus interdum accumsan leo eu adipiscing. Integer accumsan elit non turpis
            faucibus porttitor. Aliquam scelerisque nisi et turpis pretium at ultricies turpis
            pharetra.
          </p>
        </article>
        <article class="main_article">
          <h1>Main Article</h1>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur in magna libero. Sed
            nec pharetra nunc. Proin eget magna id ipsum eleifend cursus sit amet nec lectus. Nunc
            quis lacus magna. Aliquam blandit, sapien ut viverra fermentum, elit tortor ornare nisi,
            in luctus sem massa pulvinar turpis. Cras tincidunt dictum urna ut ultricies. Nullam
            diam nibh, pellentesque non laoreet ut, bibendum nec mauris. Maecenas pulvinar porttitor
            laoreet. Vivamus bibendum purus nisl, eget aliquam lectus. Maecenas justo libero,
            euismod sit amet suscipit eu, vulputate eget neque. Aliquam quam est, blandit nec
            iaculis non, suscipit vel nunc. Proin et odio aliquam erat pharetra accumsan et quis
            neque. Vivamus interdum accumsan leo eu adipiscing. Integer accumsan elit non turpis
            faucibus porttitor. Aliquam scelerisque nisi et turpis pretium at ultricies turpis
            pharetra.
          </p>
        </article>
        <article class="main_article">
          <h1>Main Article</h1>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur in magna libero. Sed
            nec pharetra nunc. Proin eget magna id ipsum eleifend cursus sit amet nec lectus. Nunc
            quis lacus magna. Aliquam blandit, sapien ut viverra fermentum, elit tortor ornare nisi,
            in luctus sem massa pulvinar turpis. Cras tincidunt dictum urna ut ultricies. Nullam
            diam nibh, pellentesque non laoreet ut, bibendum nec mauris. Maecenas pulvinar porttitor
            laoreet. Vivamus bibendum purus nisl, eget aliquam lectus. Maecenas justo libero,
            euismod sit amet suscipit eu, vulputate eget neque. Aliquam quam est, blandit nec
            iaculis non, suscipit vel nunc. Proin et odio aliquam erat pharetra accumsan et quis
            neque. Vivamus interdum accumsan leo eu adipiscing. Integer accumsan elit non turpis
            faucibus porttitor. Aliquam scelerisque nisi et turpis pretium at ultricies turpis
            pharetra.
          </p>
        </article>
      </section>
      <aside id="main_aside">
        <input id="first" type="radio" name="tab" checked="checked" />
        <input id="second" type="radio" name="tab" />
        <section class="buttons">
          <label for="first">First</label>
          <label for="second">Second</label>
        </section>
        <div class="tab_item">
          <ul>
            <li class="item">
              <a href="#">
                <div class="thumbnail">
                  <img src="http://placehold.it/45x45" />
                </div>
                <div class="description">
                  <strong>HTML5 Canvas</strong>
                  <p>2012-03-15</p>
                </div>
              </a>
            </li>
            <li class="item">
              <a href="#">
                <div class="thumbnail">
                  <img src="http://placehold.it/45x45" />
                </div>
                <div class="description">
                  <strong>HTML5 Audio</strong>
                  <p>2012-03-15</p>
                </div>
              </a>
            </li>
            <li class="item">
              <a href="#">
                <div class="thumbnail">
                  <img src="http://placehold.it/45x45" />
                </div>
                <div class="description">
                  <strong>HTML5 Video</strong>
                  <p>2012-03-15</p>
                </div>
              </a>
            </li>
            <li class="item">
              <a href="#">
                <div class="thumbnail">
                  <img src="http://placehold.it/45x45" />
                </div>
                <div class="description">
                  <strong>HTML5 Semantic Web</strong>
                  <p>2012-03-15</p>
                </div>
              </a>
            </li>
          </ul>
        </div>
        <div class="tab_item">
          <ul>
            <li class="item">
              <a href="#">
                <div class="thumbnail">
                  <img src="http://placehold.it/45x45" />
                </div>
                <div class="description">
                  <strong>CSS3 Transition</strong>
                  <p>2012-03-15</p>
                </div>
              </a>
            </li>
            <li class="item">
              <a href="#">
                <div class="thumbnail">
                  <img src="http://placehold.it/45x45" />
                </div>
                <div class="description">
                  <strong>CSS3 Animation</strong>
                  <p>2012-03-15</p>
                </div>
              </a>
            </li>
            <li class="item">
              <a href="#">
                <div class="thumbnail">
                  <img src="http://placehold.it/45x45" />
                </div>
                <div class="description">
                  <strong>CSS3 Border</strong>
                  <p>2012-03-15</p>
                </div>
              </a>
            </li>
            <li class="item">
              <a href="#">
                <div class="thumbnail">
                  <img src="http://placehold.it/45x45" />
                </div>
                <div class="description">
                  <strong>CSS3 Box</strong>
                  <p>2012-03-15</p>
                </div>
              </a>
            </li>
          </ul>
        </div>
      </aside>
    </div>
    <footer id="main_footer">
      <h3>HTML5 + CSS3 Basic</h3>
      <address>Website Layout Basic</address>
    </footer>
  </body>
</html>

πŸ“• 정리

μ€‘μš”ν•œ λ‚΄μš©

  • λ ˆμ΄μ•„μ›ƒμ„ ν–‰ λ‹¨μœ„λ‘œ μƒκ°ν•˜κΈ°
  • λ ˆμ΄μ•„μ›ƒ μ΄ˆκΈ°ν™” μ½”λ“œ
  • width와 margin을 μ‚¬μš©ν•˜μ—¬ 쀑앙 μ •λ ¬ν•˜κΈ°
  • absolute와 relative μ‚¬μš© 그리고 heightλ₯Ό ν†΅ν•œ μ˜μ—­ 확보
  • overflow와 float을 μ‚¬μš©ν•΄μ„œ λ ˆμ΄μ•„μ›ƒ λ‚˜λˆ„λŠ” 방법