170201 ์ ๋ค์ํฐ
Responsive Web Design Fundamentals
์ปดํจํฐ๋ณด๋ค ๋ชจ๋ฐ์ผ์ ๋ ๋ง์ด ์ด์ฉํ๋ ์ธ์์ด๋ค. ๊ทธ๋ฌ๋ฏ๋ก response design์ ํ์ง ์์ผ๋ฉด ์๋๋ค. ๋ค์ํ ๊ธฐ๊ธฐ์ size๋ณ๋ก ์ ์ฉ์ด ๋๋๋ก ํด์ผํ๋ค.
Simulator / Emulator
Emulator๋ ํ ์์คํ
์์ ๋ค๋ฅธ ์์คํ
์ ๋ณต์ ํ๋ค. ๊ทธ๋ฆฌํ์ฌ ๋ ๋ฒ์งธ ์์คํ
์ด ์ฒซ ๋ฒ์งธ ์์คํ
์ ๋ฐ๋ผ ํ๋ํ๋ ๊ฒ์ด๋ค. ์ธ๋ถ์ ํ๋์ ๋ํด ๋๊ฐ์ด ๋ฐ๋ผํ๋ ค๊ณ ํ๋ ์ด ๊ด์ ์ ์๋ฎฌ๋ ์ด์
๊ณผ๋ ์ ๋ฐ๋์ด๋ค. ์๋ํ๋ฉด, ์๋ฎฌ๋ ์ด์
์ ์์ฃผ ๋ด๋ถ ์ํ์ ๊ด๋ จํ์ฌ, ํ๋ด๋ด๋ ์์คํ
์ ์ถ์์ ์ธ ๋ชจ๋ธ๊ณผ ๊ด๊ณ๊ฐ ์๊ธฐ ๋๋ฌธ์ด๋ค. Simulation์ ์ค์ ๋ก ์คํํ๊ธฐ ์ด๋ ค์ด ์คํ์ ๊ฐ๋จํ ํํ๋ ๋ชจ์์คํ์ ๋ปํ๋ค.
crome Web Development : โ+โฅ+j
Pixels
Device Independent Pixels
Hardware Pixels / DPR = DIP
setting the viewport
Copy <meta name="viewport" content="width=device-width,initial=scale=1">
viewport๋ฅผ ์
ํ
ํ๋ ๊ฒ์ ์์ง๋ง๋ผ!
CSS๋ viewport๊ฐ overview๋๋ ๊ฒ์ ํ๋ฝํ๋ค.
Copy img , embed , object , video {
max-width : 100 %
}
๋ฅผ ์ค์ ํด์ฃผ๋ ๊ฒ์ ์ถ์ฒํ๋ค.
์ ์ด๋ ํด๋ฆญ(๋ณด์ฌ์ผ)ํ๋๊ฑด 48px ๋ ๋์ด์ผํ๋ค.
Copy button {
min-width : 48 px ;
min-height : 48 px ;
}
https://www.w3.org/community/webed/wiki/CSS/Properties#Border
Stylesheet
Copy <link rel="stylesheet" media="screen and (min-width: 500px)" href="name.css">
media
Copy @media screen and ( min-width : 500 px ){
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
Copy display: flex;
flex-wrap : wrap;
flex๋ row๊ฐ ๊ธฐ์ค์ด๋ค. flex-wrap: wrap์ ๊ฐ๋ ค์ง๋ ๊ฒฝ์ฐ ๋ค์์ค๋ก!
Copy header { width : 100 % ; order : 1 ;}
.red { width : 50 % ; order : 2 ; }
order์ ๋ํ๋๋ ์์๋ฅผ ๋ํ๋ธ๋ค.
Patterns
Mostly Fluid
Copy <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>
Copy .container {
display : flex ;
flex-wrap : wrap ;
}
.box {
width : 100 % ;
}
@media screen and ( min-width : 450 px ){
.light_blue , .green {
width : 50 % ;
}
}
@media screen and ( min-width : 550 px ){
.dark_blue , .light_blue , {
width : 50 % ;
}
.green , .red , .orange {
width : 33.333333 % ;
}
}
@media screen and ( min-width : 700 px ){
.container {
width : 700 px ;
margin-left : auto ;
margin-right : auto ;
}
}
Layout Shifter
Copy <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>
Copy .container {
width : 100 % ;
display : flex ;
flex-wrap : wrap ;
}
.box {
width : 100 % ;
}
@media screen and ( min-width : 500 px ){
.dark_blue {
width : 50 % ;
}
#container2 {
width : 50 % ;
}
}
@media screen and ( min-width : 600 px ){
.dark_blue {
width : 25 % ;
order : 1 ;
}
#container2 {
width : 50 % ;
}
.red {
width : 25 % ;
order : -1 ;
}
}
Column Drop
Copy <div class="container">
<div class="box dark_blue"></div>
<div class="box light_blue"></div>
<div class="box green"></div>
</div>
Copy .container {
display : flex ;
flex-wrap : wrap ;
}
.box {
width : 100 % ;
}
@media screen and ( min-width : 450 px ){
.dark_blue {
width : 25 % ;
}
.light_blue {
width : 75 % ;
}
}
@media screen and ( min-width : 550 px ){
.dark_blue , .green {
width : 25 % ;
}
.light_blue {
width : 50 % ;
}
}
Off Canvas
Copy menu .addEventListener ( 'click' , function (e) {
drawer . classList .toggle ( 'open' );
e .stopPropagation ();
});
Copy nav {
width : 300 px ;
position : absolute ;
/* This trasform moves the drawer off canvas. */
-webkit-transform : translate (-300 px , 0) ;
transform : translate (-300 px , 0) ;
/* Optionally, we animate the drawer. */
transition : transform 0.3 s ease ;
}
nav .open {
-webkit-transform : translate (0 , 0) ;
transform : translate (0 , 0) ;
}
@media screen and ( min-width : 600 px ){
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 :
Copy table {
border : 1 px solid #ddd ;
}
tr :nth-child ( odd ) {
background-color : #f9f9f9 ;
}
@media screen and ( max-width : 500 px ) {
table , thead , tbody , th , td , tr {
display : block ;
}
thead tr {
position : absolute ;
top : -9999 px ;
left : -9999 px ;
}
td {
position : relative ;
padding-left : 50 % ;
}
td :before {
position : absolute ;
left : 6 px ;
content : attr (data-th) ;
font-weight : bold ;
}
td :first-of-type {
font-weight : bold ;
}
}
Copy td {
min-width : 75 px ;
text-align : center ;
}
th :first-of-type {
min-width : 125 px ;
}
div {
width : 50 % ;
overflow-x : auto ;
}
Minor BreakPoints
:fontsize, icon size๊ณผ ๊ฐ์ ์ฌ์ํ ๋ณํ