๋ฐ์ํ์นํ์ด์ง ๋ฅผ ๋ง๋ค๋ ์ฌ์ฉํ๋ค.
ํน์ ๋ถ๋ถ์ ๋ฏธ๋์ด์ฟผ๋ฆฌ๋ก BreakPoints ๋ฅผ ์ค์ ํด์ ๋ฐ์ํ ์นํ์ด์ง๋ฅผ ๋ง๋ฌ
|
1. ์ฅ์น (๋ทฐํฌํธ ํฌ๊ธฐ๊ฐ ๋ค๋ฅธ ๊ฒฝ์ฐ)
/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {...}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {...}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {...}
/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {...}
/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {...}
2. ๋ฉ๋ด
float : left ๋ฅผ none ๊ฐ์ผ๋ก ๋ฐ๊ฟ ๋ค์ ์ธ๋ก๋ก ๋ณผ ์ ์๊ฒ ํจ
๋ width ๊ฐ์ 100%์ผ๋ก ํ์ฌ ํ๋ฉด์ ๊ฝ ์ฐจ๊ฒ ํ์์
/* The navbar container */
.topnav {
overflow: hidden;
background-color: #333;
}
/* Navbar links */
.topnav a {
float: left;
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* On screens that are 600px wide or less, make the menu links stack
on top of each other instead of next to each other */
@media screen and (max-width: 600px) {
.topnav a {
float: none;
width: 100%;
}
}
3. ์ด Columns
+ ์์ฆ์๋ flex ๋ฅผ ์ฌ์ฉํ๋ค. (CSS Flexbox)
/* Container for flexboxes */
.row {
display: flex;
flex-wrap: wrap;
}
/* Create four equal columns */
.column {
flex: 25%;
padding: 20px;
}
/* On screens that are 992px wide or less, go from four columns to two columns */
@media screen and (max-width: 992px) {
.column {
flex: 50%;
}
}
/* On screens that are 600px wide or less, make the columns stack
on top of each other instead of next to each other */
@media screen and (max-width: 600px) {
.row {
flex-direction: column;
}
}
width ๊ฐ์ %๋ก ์กฐ์ ํ์ฌ ํฌ๊ธฐ๋ณ๋ก ์ด ๋ชจ์์ ๋ฐ๊ฟ
/* Create four equal columns that floats next to each other */
.column {
float: left;
width: 25%;
}
/* On screens that are 992px wide or less, go from four columns to two columns */
@media screen and (max-width: 992px) {
.column {
width: 50%;
}
}
/* On screens that are 600px wide or less, make the columns stack
on top of each other instead of next to each other */
@media screen and (max-width: 600px) {
.column {
width: 100%;
}
}
4. ์์ ์จ๊ธฐ๊ธฐ
display : none ๊ฐ์ ์ด์ฉํ๋ฉด ํน์ ํฌ๊ธฐ์์ ์์๋ฅผ ์จ๊ธธ ์ ์๋ค.
display: none;
5. ๋ฐฉํฅ ๋ณ
orientation ๊ฐ์ ์ฌ์ฉํ๋ฉด ๋ฐฉํฅ๋ณ๋ก ์์ฑ์ ๋ฐ๊ฟ ์ ์๋ค.
@media only screen and (orientation: landscape) {
body {
background-color: lightblue;
}
}
6.์ต๋ ์ต์๊ฐ ์ง์
max-width and min-width ๊ฐ์ ํตํด์ ์ต์,์ต๋ ๋๋น๋ฅผ ์ค์ ํ ์ ์์
์ค์ ํ ๊ฐ์์๋ง ์์ฑ์ด ์๋ํจ.
์ถ๊ฐ๊ฐ์ ์ฌ์ฉํ ์์๋ OR ์ฐ์ฐ์ ์ฒ๋ผ ์๋ํจ. (๋ ์ค ํ๋ ์ฐธ์ด๋ฉด ์ฐธ)
@media screen and (max-width: 900px) and (min-width: 600px) {
}
/* ์ถ๊ฐ ๊ฐ ์ฌ์ฉ, OR ์ฐ์ฐ์ ์ฒ๋ผ ์๋ */
@media screen and (max-width: 900px) and (min-width: 600px), (min-width: 1100px) {
}