FDS12_Markup_Summary

Responsive Web | Responsive <img>, <video> and <iframe> | Grid

반응형 웹 | Responsive Web Design

One Source Multi Use : 반응형 웹의 필요성 대두

Flexible vs Adaptive

DeskTop First vs Mobile First

Flexible Layout

Media Queries

@charset "utf-8"
/* All Device */
/* Mobile Device */
@media all and (min-width: 768px){
  /* 사용자 해상도가 768px 이상일 때 실행됨 */
}

Responsive Image

img{
  max-width: 100%;
  height: auto;
}

• 용량으로 인한 성능, 속도 고려 필요

• Mobile Responsive Web test site: Troy - Responsive web tester

• 현재 기기의 Pixel Ratio 알 수 있는 사이트: myDevice.io

image

• 다양한 Image Format 대응

• 해결

반응형 이미지

.rwd-container{
  width: 50%;
  box-sizing: border-box;
  border: 10px solid #000;
}
.rwd-container img, .rwd-container video{
  width: 100%;
  height: auto;
}

<iframe>을 반응형으로 만들기

  1. <iframe> 삽입 image

     <div class="rwd-iframe">
       <iframe src="https://www.youtube.com/embed/2S24-y0Ij3Y?controls=0" allowfullscreen></iframe>
     </div>
    
     .rwd-iframe{
       border: 10px solid #00f;
       width: 80%;
     }
     .rwd-iframe iframe{
       width: 100%;
       height: auto;
     }
    
  1. 비율별 module화

     .rwd-iframe{
       position: relative;
       padding-top: calc(9 / 16 * 100%);
       background: pink;
       width: 100%;
     }
     .rwd-3-4{
       padding-top: calc(3 / 4 * 100%);
     }
     .rwd-9-16{
       padding-top: calc(9 / 16 * 100%);
     }
    
    
     <div class="rwd-container">
       <div class="rwd-iframe rwd-9-16">
         <iframe src="https://www.youtube.com/embed/2S24-y0Ij3Y?controls=0" allowfullscreen></iframe>
       </div>
     </div>
     <div class="rwd-container">
       <div class="rwd-iframe rwd-3-4">
         <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2974.021471174445!2d127.05441626516713!3d37.54323347980236!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca49534790c57%3A0xc115101cbaecb40e!2z7JWE7YGs67C466as7ISc67mE7Iqk!5e1!3m2!1sko!2skr!4v1555310320240!5m2!1sko!2skr" allowfullscreen></iframe>
       </div>
     </div>
    
    

GRID

Container에 display: grid 적용

  .container{
    display: grid;
  }

Grid-template

  .container{
    display: grid;
    grid-template-columns: 50% 50%;
    grid-template-rows: 50% 50%;
  }

image

Grid fraction

  .container{
    background: yellow;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 100px 100px;
  }

image

Grid 배치

  .items4{
    background: lime;
    grid-column-start: 2;
    grid-column-end: 3;
    grid-row-start: 1;
    grid-row-end: 2;
  }

image

여러 track 차지하기

  .items2{
    background: orange;
    grid-column: 1 / 4;
    grid-row: 2 / 3;
  }

image

Grid-area

  .items2{
    background: orange;
    /* row-start / column-start / row-end / column-end */
    grid-area: 2 / 1 / 3 / 4;
  }

Grid template areas

.container{
  background: yellow;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 100px 100px;
  grid-template-areas: "item2 . item1" 
          "item4 item4 item3"
}

image

Grid column, gutter(gap) 설정

.container{
  background: yellow;
  display: grid;
  grid-template-columns: repeat(12, 65px);
  grid-column-gap: 20px; 
}

: repeat(반복 횟수, 크기) method 사용 image

.container{
  max-width: 1000px;
  margin: 0 auto;
  background: silver;
  display: grid;
  grid-template-columns: repeat(12, 65px);
  /* grid-template-rows: ; */
  grid-column-gap: 20px; 
}
.header{
  background: pink;
  grid-area: 1 / 1 / 2 / 13;
}
.navigation{
  background: skyblue;
  grid-area: 2 / 1 / 3 / 13;
}
.book{
  background: lime;
  grid-area: 3 / 1 / 4 / 5;
}
.news{
  background: orange;
  grid-area: 3 / 5 / 4 / 13;
}
.board{
  background: blanchedalmond;
  grid-area: 4 / 1 / 5 / 5;
}
.favorite{
  background: gold;
  grid-area: 4 / 10 / 5 / 13;
}
.twitter{
  background: brown;
  grid-area: 4 / 5 / 5 / 10;
}
.footer{
  background: teal;
  grid-area: 5 / 1 / 6 / 13;
}

image