๋ฐ์ํ ์น์ ๋ง๋ค๊ธฐ ์ํด ๋ฐ๋์ ์์์ผ ํ๋ CSS ์ ์ธ ์ค ํ๋
Responsive Web?
- ๋ฐ์คํฌํ ๋ฟ๋ง ์๋๋ผ ๋ชจ๋ฐ์ผ, ํ๋ธ๋ฆฟ์ ํ๋ฉด์ ๋ฑ ๋ง๊ฒ ๋ณด์ผ ์ ์๊ฒ ํ๋ ๊ฒ
- viewport meta์ media query๊ฐ ํ์ํ๋ค.
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@media screen and (min-width: 768px) {
/* Where all the magic happens... */
}
width: 100%; height: 100vh;
).class-name {
display: flex;
justify-content: center;
align-item: center;
}
- Typography: ํ ์คํธ๋ฅผ ์์๊ฒ ๋์์ธ ํ๋ ๊ฒ
font-size
: ๊ธ์ ํฌ๊ธฐ<html>
์ em. html์ ์ ์ฉ๋ ํฐํธ ์ฌ์ด์ฆ๊ฐ 1rem์ด ๋๋ค..text {
font-family: "Poppins";
font-family: "Poppins", sans-serif; /* Poppins ํฐํธ๊ฐ ์์ผ๋ฉด sans-serif ์๋ฌด๊ฑฐ๋ ์ ์ฉํด๋ผ */
font-family: "Poppins", "Roboto", sans-serif;
}
font-weight: 100 | 200 | 300 | 400 | 500 | 600 | 700| 800 | 900
text-indent: 10px;
- Icon์ ๋ง๋ค๊ฑฐ๋ ์ด๋ฏธ์ง๋ฅผ ๋ช ์ํ ๋ ์ฌ์ฉ
background-color
: ๋ฐฐ๊ฒฝ์background-image
: ๋ฐฐ๊ฒฝ ์ด๋ฏธ์งurl()
ํ์ํจbackground-repeat
background-size
50% auto
)background-position: center center;
๋ง์ด ์ฌ์ฉ
- ๋งํฌ์ ์ ๊ธฐ๋ณธ ์ธํ ๋จผ์ ํ๊ธฐ
- box-sizing, margin ์ธํ
- font ์ค์
- ์ด๋ฏธ์ง html ์ฒ๋ฆฌ | css์์ bg๋ก ์ฒ๋ฆฌ
- ๋ถ๋ชจ ์์์ ํฌ๊ธฐ๊ฐ ์ ํด์ ธ ์๋ ๊ฒฝ์ฐ, html์์ img ํ๊ทธ๋ก ์ด๋ฏธ์ง ์ฝ์ ์ ์ธ๋ก๊ฐ ๊ธด ์ด๋ฏธ์ง์ธ์ง, ๊ฐ๋ก๊ฐ ๊ธด ์ด๋ฏธ์ง์ธ์ง์ ๋ฐ๋ผ ์์ ์ ๋ ํด์ค์ผํ๋ ๊ฒฝ์ฐ๊ฐ ์๊ธธ ์ ์์. ๊ต์ฅํ ๋ฒ๊ฑฐ๋กญ๊ธฐ ๋๋ฌธ์ bg๋ก ์ฒ๋ฆฌํ๋ฉด ์ข๋ค. ๋ชจ๋ css ์์ ํ ๋ ๋ ผ๋ฆฌ์ ์ผ๋ก ์๊ฐํ๋ฉด์ ๋งํฌ์ ์ ํ์.
strong
๊ณผspan
๋ inline ํ๊ทธ!!!! ๋ง์ง์ด๋ ํจ๋ฉ top-bottom ์ค ๋ display ๋ณ๊ฒฝํด์ฃผ์๐- html์ ๋งํฌ์ ์ด ๋์ด์์ง ์๋ ์์๋ฅผ ์ถ๊ฐํ ๋, ๊ทธ๊ฒ symanticํ ์์๊ฐ ์๋ ๊ฒฝ์ฐ์๋ ๊ฐ์ ์ ๋ ์ด์ฉํ๊ธฐ
- ๊ฐ๋ก๋ฐฐ์น๋ ๋งํฌ์ ํ์ ์งํํ๊ธฐ
- flex-grow: ๊ณต๊ฐ์ด ๋จ์ผ๋ฉด ํ๋ ์ค ์ ์ฉํ ์์๊ฐ ๊ทธ ๊ณต๊ฐ์ ์ฐจ์งํ ๊ฒ์ธ์ง ์ ํด์ฃผ๋ ํ๋กํผํฐ
flex-grow: 1;
display:none
์ ํ๊ฒ ๋๋ฉด ์คํฌ๋ฆฐ ๋ฆฌ๋๊ฐ ์ธ์ํ์ง ๋ชปํจwidth
๋height
์ 0์ ์ค๋ ์คํฌ๋ฆฐ ๋ฆฌ๋๊ฐ ์ธ์ํ์ง ๋ชปํจ- ์ง ๋๊ฐ ์ ์ทจ๊ธํด๋ฒ๋ฆฌ๊ธฐ =>
position: absolute
.sr-only { position: absolute; z-index: -100; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
- ์ด๋ค ์์์ ๋ณํ๋ฅผ ์ค ๋ ์์ฐ์ค๋ฝ๊ฒ ์ค๋ฅด๋ฅต ์ ํํ๊ฒ ๋ง๋๋ ์์
- property | duration | [timing-function] | [delay]
์ ๊ฐ์ ์์๋ค์ด ๋ช ์๋์ด์ผ ํจ []๋ ์๋ต ๊ฐ๋ฅ
- animation vs. transition
- transition์ ์ ํ. ์ด๋ฏธ ์ ์ธํด๋์ ํ๋กํผํฐ ๊ฐ์ด ๋ถ๋๋ฝ๊ฒ ๋ฐ๋ ๋ ์ฌ์ฉ
- animation์ ๋ณ๊ฐ๋ก animation์ ์ฃผ๊ณ ์ถ์ ๋ ์ค ์ ์์. ๋ ์์ ๋ก์
- @keyframes: ์ด๋ค ์์ผ๋ก ์ ๋๋ฉ์ด์ ์ด ๋์ํ๋์ง ์ ์ํด์ฃผ์ด์ผ ํจ.
- from to๋ %๋ก ๋ณํ์ํฌ ์์๋ค ์์ฑ
@keyframes name {
from {
/* Rules */
}
to {
/* Rules */
}
}
@keyframes name {
0% {
/* Rules */
}
50% {
/* Rules */
}
100% {
/* Rules */
}
}
- mdn์์ ์์นํ๋ฉด์ ์ฌ์ฉํด๋ณด๊ธฐ
- ๊ทธ๋ฆผ์ ์ฃผ๊ธฐ
h-offset | v-offset | blur | spread | color
(x์ถ ์ด๋ ํฌ๊ธฐ | y์ถ ์ด๋ ํฌ๊ธฐ | ํ๋ฆฐ ์ ๋ | ๊ทธ๋ฆผ์ ์ฌ์ด์ฆ | ์์)
- width์ height๋ฅผ ๊ฐ์ง ์ ์๋ ์์ ์์ ์์ ์์๋ ์ปจํ ์ธ ๊ฐ ํด๋น ์์์ ํฌ๊ธฐ๋ฅผ ๋ฒ์ด๋ฌ์ ๋ ์ด๋ค ์์ผ๋ก ์ฒ๋ฆฌํ ์ง์ ๋ํ ์์ฑ๐
- visible | auto | scroll | hidden
1. visible
overflow์ ๊ธฐ๋ณธ๊ฐ
๊ทธ๋ฅ ๋ณด์ด๊ฒ ๋๋
ํฐ์ ธ ๋๊ฐ ์ปจํ
์ธ ๋ ๋ค๋ฅธ ์์ ์์๋ค์ด ๊ฐ๋ฌด์ํจ
2. auto, scroll
๋์ณ ํ๋ฅธ ์ ๋ค ์๋์ผ๋ก ์คํฌ๋กค ์์ฑ
3. hidden
๋์ณ ํ๋ฅธ ์ ๋ค ๊ฐ๋ ค๋ฒ๋ฆผ
overflow-x | overflow-y: x, y์ถ ๋ฐ๋ก ์ค์ ๊ฐ๋ฅ
- ์์๋ฅผ 2์ฐจ์/3์ฐจ์์ ๊ณต๊ฐ์์ ๋ณํํ๊ณ ์ถ์๋๋ก ๋ณํํ ์ ์๋ ์์ฑ
- translate() | scale() | rotate()
1. translate(x, y)
์ํ๋ ๋ฐฉํฅ์ผ๋ก ์ฎ๊ธธ ๋ ์ฌ์ฉ
์ด๋ํด๋ ์๋ ์์น๋ ๋ชจ๋๊ฐ ๊ธฐ์ตํจ. ๋ค๋ฅธ ์์๋ค์๊ฒ ์ํฅ ์ฃผ์ง ์์
๋จ์๋ px, %๋ ๊ฐ๋ฅ. %๋ ์๊ธฐ ์์ ์ ์๋๊ฐ
position absolute์์ ๊ฐ์ด๋ฐ ์ ๋ ฌ ์์๋ ์ฌ์ฉํจ translate(-50%, -50%)
2. scale(N), scale(x, y)
๋ฐฐ์จ
๋ค๋ฅธ ์์๋ค์๊ฒ ์ํฅ x
๊ฐ์ ์๊ธฐ ์์ ์ ์๋๊ฐ
3. rotate(Ndeg)
๊ฐ๋ ์กฐ์
deg๋ฅผ ์์ฑํด์ฃผ์ด์ผ ํจ (transform: rotate(90deg)
)
๋ค๋ฅธ ์์๋ค์๊ฒ ์ํฅ x
- ๋ณด์ด๊ฒ / ์ ๋ณด์ด๊ฒ ํ๋ ์์ฑ
- visible | hidden
hidden
๋ณด์ด์ง๋ง ์๋ ๊ฒ. opacity 0๊ณผ ๋น์ทํ ์ํฉ
display: none;
๊ณผ์ ์ฐจ์ด์ ?
box์ ํ์
์ด ์๋ ๊ฒ. ์๋ ๋ฐ์ค ์ทจ๊ธํจ
- ๋จ๊ธฐ๊ฐ์ ๋ง์ ๋ด์ฉ์ ์ตํ๋ค ๋ณด๋ ์ฌ์ฌ ์ ์ ๋ฐฐ์ ๋ ๊ฒ๋ค์ด ๊ธฐ์ต ์๋๊ธฐ ์์ํ๋ค๐ต ๋ณต์ตํด์ผ์ง...
- ์ฌ๋ฐ๋๋ฐ ์ด๋ ต๊ณ ์ฌ๋ฐ๋น๐
- css๋ฅผ ๋ด๊ฐ ๋ค ์ง๋ค ๋ณด๋ ์ค์ต์ด ์ค๋ ๊ฑธ๋ฆฐ๋ค. ์ฐ์ต์ ๊พธ์คํ ํด์ผ๊ฒ ๋ค.
- ์ด๊ฑฐ ๋ค ๋ฃ๊ณ ๋๋ฉด js ๊ณต๋ถํ ์์ ์ธ๋ฐ js ๊ณต๋ถํ๋ฉด์ ์์ ๊ฑฐ๋ผ๋ ํด๋ก ์ฝ๋ฉ ์ฐ์ต์ ํด์ผ๋ ๋ฏ