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

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

πŸ“– 1. 슀마트폰 λ ˆμ΄μ•„μ›ƒ

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

μ΅œκ·Όμ—λŠ” HTML, CSS, Javascriptλ₯Ό ν™œμš©ν•΄ λ„€μ΄ν‹°λΈŒ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ„ λ§Œλ“œλŠ” React Native, Vue Nativeλ“±μ˜ 기술이 ν™œμ„±ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
이와 같은 λ°©λ²•μœΌλ‘œ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ„ λ§Œλ“€λ©΄, 아이폰 및 μ•ˆλ“œλ‘œμ΄λ“œ λ“±μ˜ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ„ λ”°λ‘œ κ°œλ°œν•  ν•„μš”κ°€ 없이 λͺ¨λ“  OSμ—μ„œ μ‹€ν–‰ν•  수 μžˆλ‹€λŠ” μž₯점이 μžˆμŠ΅λ‹ˆλ‹€. πŸ‘

<!DOCTYPE html>
<html>
  <head>
    <title>Chapter 6</title>
    <!-- 🌟 뷰포트: λͺ¨λ°”일 μ›Ή νŽ˜μ΄μ§€λŠ” 화면에 λŒ€ν•œ νŠΉλ³„ν•œ 정보λ₯Ό μ œκ³΅ν•˜κΈ° μœ„ν•΄ 뷰포트 meta νƒœκ·Έλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.
    λΈŒλΌμš°μ €μ˜ ν™”λ©΄ μ„€μ •κ³Ό κ΄€λ ¨λœ 정보λ₯Ό μ œκ³΅ν•©λ‹ˆλ‹€.
    ----
      initial-scale: 초기 ν™•λŒ€ λΉ„μœ¨
      user-scalable: ν™•λŒ€ 및 μΆ•μ†Œ κ°€λŠ₯ μ—¬λΆ€
      minimum-scale: μ΅œμ†Œ μΆ•μ†Œ λΉ„μœ¨
      maximum-scale: μ΅œλŒ€ ν™•λŒ€ λΉ„μœ¨
    ----
    -->

    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no"
    />
    <!-- μ΄ˆκΈ°ν™” -->
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        font-family: 'Helvetica', sans-serif;
      }
      li {
        list-style: none;
      }
      a {
        text-decoration: none;
      }
    </style>
    <!-- 헀더 -->
    <style>
      #main_header {
        /* λ°°κ²½ 지정 */
        height: 45px;
        background: url('header_background.png');

        /* μžμ† μœ„μΉ˜ 지정 */
        position: relative;
        text-align: center;
        line-height: 45px;
      }
      #main_header > h1 {
        color: white;
      }
      #main_header > a,
      #main_header > label {
        display: block;
        height: 32px;
        position: absolute;
      }
      #main_header > a.left {
        width: 62px;
        left: 5px;
        top: 7px;
      }
      #main_header > label.right {
        width: 32px;
        right: 5px;
        top: 7px;
      }
    </style>
    <!-- 🌟 μŠ€ν”„λΌμ΄νŠΈ 이미지: 이미지λ₯Ό μ—¬λŸ¬ 개 뭉쳐놓은 것을 μ˜λ―Έν•©λ‹ˆλ‹€. μ΄λ ‡κ²Œ μ—¬λŸ¬κ°œμ˜ 이미지λ₯Ό 1개의 μ΄λ―Έμ§€λ‘œ λ­‰μ³μ„œ μ‚¬μš©ν•˜λ©΄ 
    μ›Ή νŽ˜μ΄μ§€ μš”μ²­ μ‹œκ°„μ„ 쀄이고 μ‰½κ²Œ 관리할 수 μžˆμŠ΅λ‹ˆλ‹€.
    μŠ€ν”„λΌμ΄νŠΈ 이미지 λ§Œλ“€κΈ°: https://www.toptal.com/developers/css/sprite-generator/ -->
    <style>
      #main_header > a.left {
        background: url('sprites.png');
        background-position: 0px 0px;
        text-indent: -99999px;
        /* 🌟 ν…μŠ€νŠΈλ₯Ό λ“€μ—¬μ“°κΈ°, λ‚΄μ–΄μ“°κΈ°ν•˜λŠ” μš©λ„λ‘œ, μ—¬κΈ°μ„œλŠ” νƒœκ·Έ λ‚΄λΆ€ κΈ€μžλ₯Ό μ•ˆλ³΄μ΄κ²Œ ν•˜λ € μ•„μ£Ό μ™Όμͺ½ 끝으둜 보내버린 κ²ƒμž…λ‹ˆλ‹€.
        κΈ€μžλ₯Ό μž…λ ₯ν•˜μ§€ μ•Šμ•„λ„ 되긴 ν•˜μ§€λ§Œ, κ·Έ μžλ¦¬κ°€ μ–΄λ– ν•œ μš©λ„μΈμ§€ μ•ŒκΈ° μ‰½κ²Œ μ΄λ ‡κ²Œ μ‚¬μš©ν•˜κΈ°λ„ ν•©λ‹ˆλ‹€. */
      }
      #main_header > label.right {
        background: url('sprites.png');
        background-position: -62px 0px;
        text-indent: -99999px;
      }
    </style>
    <!-- ν† κΈ€ λͺ©λ‘ -->
    <style>
      /* ν† κΈ€ κ΅¬ν˜„ */
      #toggle {
        display: none;
      }
      #toggle + #wrap > #toggle_gnb_wrap {
        display: none;
      }
      #toggle:checked + #wrap > #toggle_gnb_wrap {
        display: block;
      }

      /* λ ˆμ΄μ•„μ›ƒ 색상 */
      #toggle_gnb_wrap {
        background: #363636;
        padding: 15px;
      }
      #toggle_gnb {
        background: #ffffff;
        padding: 5px;
      }

      /* ν† κΈ€ λͺ©λ‘ */
      #toggle_gnb > ul {
        overflow: hidden;
      }
      #toggle_gnb > ul > li {
        width: 80px;
        float: left;
      }
    </style>
    <!-- 🌟 λ„€λΉ„κ²Œμ΄μ…˜(1): overflow와 float을 μ‚¬μš©ν•˜μ—¬ navλ₯Ό λ§Œλ“œλŠ” λ°©λ²•μž…λ‹ˆλ‹€. -->
    <style>
      #top_gnb {
        overflow: hidden;
        border-bottom: 1px solid black;
        background: #b42111;
      }
      #top_gnb > div > a {
        /* μˆ˜ν‰ μ •λ ¬ */
        float: left;
        width: 25%;

        /* 크기 및 색상, μ •λ ¬ */
        height: 35px;
        line-height: 35px;
        text-align: center;
        color: white;
      }
    </style>
    <!-- 🌟 λ„€λΉ„κ²Œμ΄μ…˜(2): display에 table ν‚€μ›Œλ“œλ₯Ό μ‚¬μš©ν•˜μ—¬ navλ₯Ό λ§Œλ“œλŠ” λ°©λ²•μž…λ‹ˆλ‹€. -->
    <style>
      #bottom_gnb {
        display: table;
        width: 100%;
        border-bottom: 1px solid black;
      }
      #bottom_gnb > div {
        display: table-cell;
        position: relative;
      }
      #bottom_gnb > div > a {
        display: block;
        height: 35px;
        line-height: 35px;
        text-align: center;
      }
      /* 🌟 ::beforeλ₯Ό μ‚¬μš©ν•˜μ—¬ 각 μš”μ†Œ μ•ž(이전)에 검은색 μˆ˜μ§μ„ μ„ λ§Œλ“­λ‹ˆλ‹€. */
      #bottom_gnb > div > a::before {
        display: block;
        position: absolute;
        top: 9px;
        left: -1px;
        width: 1px;
        height: 15px;
        border-left: 1px solid black;
        content: '';
      }
    </style>
    <!-- λ³Έλ¬Έ -->
    <style>
      #section_header {
        padding: 20px;
      }
      #section_article {
        padding: 10px;
      }
    </style>
    <!-- ν‘Έν„° -->
    <style>
      #main_footer {
        padding: 10px;
        border-top: 3px solid black;
        text-align: center;
      }
    </style>
  </head>
  <body>
    <input id="toggle" type="checkbox" />
    <!-- 🌟 body μžμ²΄μ— μŠ€νƒ€μΌμ„ μ μš©ν•˜λŠ” 것이 μœ„ν—˜ν•  μˆ˜λ„ μžˆλ‹€κ³  μƒκ°ν•˜λŠ” κ°œλ°œμžλ“€μ΄ #wrap인 divλ₯Ό λ”°λ‘œ λ§Œλ“€κΈ°λ„ ν•©λ‹ˆλ‹€.
    λ¬Όλ‘  λ°˜λ“œμ‹œ 이런 κ²½μš°κ°€ μ•„λ‹ˆλ”λΌλ„ νŠΉλ³„ν•œ κ²½μš°μ— μ‚¬μš©ν•˜κΈ°λ„ ν•©λ‹ˆλ‹€.
    μ—¬κΈ°μ„œλŠ” 일뢀 슀마트폰 μ›Ή λΈŒλΌμš°μ €λŠ” ~ μ„ νƒμž μ‚¬μš©μ΄ λΆˆκ°€λŠ₯ν•˜κΈ°μ— μ‚¬μš©ν•˜μ˜€μŠ΅λ‹ˆλ‹€. -->
    <div id="wrap">
      <header id="main_header">
        <a class="left" href="#">Main</a>
        <h1>Mobile</h1>
        <label class="right" for="toggle" onclick="">Toggle</label>
      </header>
      <div id="toggle_gnb_wrap">
        <div id="toggle_gnb">
          <ul>
            <li><a href="#">λ²„νŠΌ</a></li>
            <li><a href="#">λ²„νŠΌ</a></li>
            <li><a href="#">λ²„νŠΌ</a></li>
            <li><a href="#">λ²„νŠΌ</a></li>
            <li><a href="#">λ²„νŠΌ</a></li>
            <li><a href="#">λ²„νŠΌ</a></li>
            <li><a href="#">λ²„νŠΌ</a></li>
            <li><a href="#">λ²„νŠΌ</a></li>
          </ul>
        </div>
      </div>
      <nav id="top_gnb">
        <div><a href="#">λ²„νŠΌ</a></div>
        <div><a href="#">λ²„νŠΌ</a></div>
        <div><a href="#">λ²„νŠΌ</a></div>
        <div><a href="#">λ²„νŠΌ</a></div>
      </nav>
      <nav id="bottom_gnb">
        <div><a href="#">λ²„νŠΌ</a></div>
        <div><a href="#">λ²„νŠΌ</a></div>
        <div><a href="#">λ²„νŠΌ</a></div>
        <div><a href="#">λ²„νŠΌ</a></div>
        <div><a href="#">λ²„νŠΌ</a></div>
      </nav>
      <section id="main_section">
        <header id="section_header">
          <h1>Lorem ipsum</h1>
          <time>2012-12-09 - Birthday</time>
        </header>
        <article id="section_article">
          <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>
          <br />
          <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>
          <br />
          <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>
      <footer id="main_footer">
        <h3>HTML5 + CSS3 Basic</h3>
        <address>Website Layout Basic</address>
      </footer>
    </div>
  </body>
</html>

πŸ“• 정리

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

  • 뷰포트 meta νƒœκ·Έ
  • μŠ€ν”„λΌμ΄νŠΈ 이미지
  • nav λ§Œλ“œλŠ” 방법
    1. overflow와 float 속성 ν™œμš©
    2. display 속성과 table ν‚€μ›Œλ“œ ν™œμš©
  • ::before μ„ νƒμžλ₯Ό μ‚¬μš©ν•˜μ—¬ μˆ˜μ§μ„  μƒμ„±ν•˜κΈ°

βž• κΈ€μž 감좔기 : Ellipsis(μƒλž΅)ν•˜λŠ” 기술

화면이 μž‘μ€ κΈ°κ³„μ—μ„œλŠ” κΈ€μžκ°€ 잘릴 수 μžˆμŠ΅λ‹ˆλ‹€.
이 λ•Œ 잘린 뢀뢄을 '...'으둜 λŒ€μ²΄ν•˜μ—¬ λ ˆμ΄μ•„μ›ƒμ΄ 깨지지 μ•Šλ„λ‘ ν•΄μ£ΌλŠ” λ°©λ²•μž…λ‹ˆλ‹€.
block ν˜•μ‹μ˜ νƒœκ·Έμ— μ•„λž˜μ™€ 같이 μŠ€νƒ€μΌλ§μ„ μ§€μ •ν•˜μ—¬ μ‚¬μš©ν•©λ‹ˆλ‹€.(주둜 h1같은 제λͺ© νƒœκ·Έμ— μ‚¬μš©ν•©λ‹ˆλ‹€.)

div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}