Udacity - Responsive Web Design

170201 ์œ ๋‹ค์‹œํ‹ฐ

Responsive Web Design Fundamentals

์ปดํ“จํ„ฐ๋ณด๋‹ค ๋ชจ๋ฐ”์ผ์„ ๋” ๋งŽ์ด ์ด์šฉํ•˜๋Š” ์„ธ์ƒ์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ response design์„ ํ•˜์ง€ ์•Š์œผ๋ฉด ์•ˆ๋œ๋‹ค. ๋‹ค์–‘ํ•œ ๊ธฐ๊ธฐ์˜ size๋ณ„๋กœ ์ ์šฉ์ด ๋˜๋„๋ก ํ•ด์•ผํ•œ๋‹ค.

Simulator / Emulator

Emulator๋Š” ํ•œ ์‹œ์Šคํ…œ์—์„œ ๋‹ค๋ฅธ ์‹œ์Šคํ…œ์„ ๋ณต์ œํ•œ๋‹ค. ๊ทธ๋ฆฌํ•˜์—ฌ ๋‘ ๋ฒˆ์งธ ์‹œ์Šคํ…œ์ด ์ฒซ ๋ฒˆ์งธ ์‹œ์Šคํ…œ์„ ๋”ฐ๋ผ ํ–‰๋™ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์™ธ๋ถ€์˜ ํ–‰๋™์— ๋Œ€ํ•ด ๋˜‘๊ฐ™์ด ๋”ฐ๋ผํ•˜๋ ค๊ณ  ํ•˜๋Š” ์ด ๊ด€์ ์€ ์‹œ๋ฎฌ๋ ˆ์ด์…˜๊ณผ๋Š” ์ • ๋ฐ˜๋Œ€์ด๋‹ค. ์™œ๋ƒํ•˜๋ฉด, ์‹œ๋ฎฌ๋ ˆ์ด์…˜์€ ์ž์ฃผ ๋‚ด๋ถ€ ์ƒํƒœ์™€ ๊ด€๋ จํ•˜์—ฌ, ํ‰๋‚ด๋‚ด๋Š” ์‹œ์Šคํ…œ์˜ ์ถ”์ƒ์ ์ธ ๋ชจ๋ธ๊ณผ ๊ด€๊ณ„๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. Simulation์€ ์‹ค์ œ๋กœ ์‹คํ–‰ํ•˜๊ธฐ ์–ด๋ ค์šด ์‹คํ—˜์„ ๊ฐ„๋‹จํžˆ ํ–‰ํ•˜๋Š” ๋ชจ์˜์‹คํ—˜์„ ๋œปํ•œ๋‹ค.

  • crome Web Development : โŒ˜+โŒฅ+j

Pixels

  • Device Independent Pixels

  • Hardware Pixels

Hardware Pixels / DPR = DIP

setting the viewport

<meta name="viewport" content="width=device-width,initial=scale=1">

viewport๋ฅผ ์…‹ํŒ…ํ•˜๋Š” ๊ฒƒ์„ ์žŠ์ง€๋งˆ๋ผ!

CSS๋Š” viewport๊ฐ€ overview๋˜๋Š” ๊ฒƒ์„ ํ—ˆ๋ฝํ•œ๋‹ค.

img, embed, object, video {
    max-width: 100%
}

๋ฅผ ์„ค์ •ํ•ด์ฃผ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค.

์ ์–ด๋„ ํด๋ฆญ(๋ณด์—ฌ์•ผ)ํ•˜๋Š”๊ฑด 48px๋Š” ๋˜์–ด์•ผํ•œ๋‹ค.

button {
    min-width: 48px;
    min-height: 48px;
}

https://www.w3.org/community/webed/wiki/CSS/Properties#Border

Stylesheet

<link rel="stylesheet" media="screen and (min-width: 500px)" href="name.css">

media

@media screen and (min-width: 500px){
    body{background-color: green;}
}

@import url("no.css") only screen and (min-width: 500px);

import tag๋Š” ํ”ผํ•ด๋ผ!

min-devise-width๋‚˜ max-devise-width์˜ ์‚ฌ์šฉ์„ ํ”ผํ•ด๋ผ. ์™œ๋ƒํ•˜๋ฉด ๊ธฐ๊ณ„์˜ ํ™”๋ฉด์˜ ๊ฐ’์„ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์ธ๋ฐ ์•ˆ๋“œ๋กœ์ด๋“œ์˜ ๊ฒฝ์šฐ์—๋Š” ์ž˜๋ชป๋œ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋‹ค.

Breakpoints

: the point a which your sites content will respond to provide the user with the best possible layout to consume the information.

  • breakpoint๋ฅผ ์–ด๋””์— ์„ค์ •ํ•ด์•ผํ•˜๋‚˜์š”?

    based on specific devices, products, brand names or anything else, will almost always result in a maintenance nigthmare.

breakpoint๋Š” ๋ฐœ๊ฒฌํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

Flexbox

display: flex;
flex-wrap: wrap;

flex๋Š” row๊ฐ€ ๊ธฐ์ค€์ด๋‹ค. flex-wrap: wrap์€ ๊ฐ€๋ ค์ง€๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ์ค„๋กœ!

header{ width: 100%; order: 1;}
.red{ width: 50%; order:2; }

order์€ ๋‚˜ํƒ€๋‚˜๋Š” ์ˆœ์„œ๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค.

Patterns

  1. Mostly Fluid

    <div class="container">
      <div class="box dark_blue"></div>
      <div class="box light_blue"></div>
      <div class="box green"></div>
      <div class="box red"></div>
      <div class="box orange"></div>
    </div>
    .container{
     display: flex;
     flex-wrap: wrap;
    }
    .box{
     width: 100%;
    }
    @media screen and (min-width: 450px){
     .light_blue, .green{
         width: 50%;
     }
    }
    @media screen and (min-width: 550px){
     .dark_blue, .light_blue,{
         width: 50%;
     }
      .green, .red, .orange{
          width: 33.333333%;
      }
    }
    @media screen and (min-width: 700px){
     .container{
         width: 700px;
         margin-left: auto;
         margin-right: auto;
     }
    }
  2. Layout Shifter

    <div class="container">
     <div class="box dark_blue"></div>
     <div class="container" id="container2">
         <div class="box light_blue"></div>
         <div class="box green"></div>
     </div>
     <div class="box red"></div>
    </div>
    .container{
     width: 100%;
     display: flex;
     flex-wrap: wrap;
    }
    .box{
     width: 100%;
    }
    @media screen and (min-width: 500px){
     .dark_blue{
         width: 50%;
     }
     #container2{
         width: 50%;
     }
    }
    @media screen and (min-width: 600px){
     .dark_blue{
         width: 25%;
         order: 1;
     }
     #container2{
         width: 50%;
     }
     .red{
         width: 25%;
         order: -1;
     }
    }
  3. Column Drop

    <div class="container">
     <div class="box dark_blue"></div>
     <div class="box light_blue"></div>
     <div class="box green"></div>
    </div>
    .container{
     display: flex;
     flex-wrap: wrap;
    }
    .box{
     width: 100%;
    }
    @media screen and (min-width: 450px){
     .dark_blue{
         width: 25%;
     }
     .light_blue{
         width: 75%;
     }
    }
    @media screen and (min-width: 550px){
     .dark_blue, .green{
         width: 25%;
     }
     .light_blue{
         width: 50%;
     }
    }
  4. Off Canvas

    menu.addEventListener('click', function(e) {
    drawer.classList.toggle('open');
    e.stopPropagation();
    });
    nav {
    width: 300px;
    position: absolute;
    /* This trasform moves the drawer off canvas. */
    -webkit-transform: translate(-300px, 0);
    transform: translate(-300px, 0);
    /* Optionally, we animate the drawer. */
    transition: transform 0.3s ease;
    }
    nav.open {
    -webkit-transform: translate(0, 0);
    transform: translate(0, 0);
    }
    @media screen and (min-width: 600px){
     nav{
          position: relative;
          transform: translate(0,0);
     }
     body{
         display: flex;
         flex-flow: row nowrap;
     }
     main{
         width: auto;
         flex-grow: 1;
     }
    }

Responsive Tables

  • Hidden Column : display: none;์€ ๋ณด์—ฌ์ง€์ง€ ์•Š๊ฒŒ ์ˆจ๊ธฐ๋Š” ๊ฒƒ.

  • No More Tables :

         table {
          border: 1px solid #ddd;
        }
        tr:nth-child(odd) {
          background-color: #f9f9f9;
        }
        @media screen and (max-width: 500px) {
          table, thead, tbody, th, td, tr {
            display: block;
          }
          thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
          }
          td {
            position: relative;
            padding-left: 50%;
          }
          td:before {
            position: absolute;
            left: 6px;
            content: attr(data-th);
            font-weight: bold;
          }
          td:first-of-type {
            font-weight: bold;
          }
        }
              td {
          min-width: 75px;
          text-align: center;
        }
        th:first-of-type {
          min-width: 125px;
        }
        div {
          width: 50%;
          overflow-x: auto;
        }

Minor BreakPoints

:fontsize, icon size๊ณผ ๊ฐ™์€ ์‚ฌ์†Œํ•œ ๋ณ€ํ™”

Last updated