๐จCSS
๊ฐ์
Cascading Style Sheet
[TOC]
์ ํ์์ ์์ฑ์ผ๋ก ๊ตฌ์ฑ
์ธ๋ฏธํด๋ก ๋น ํธ๋ฆฌ๋ฉด ์ฐพ๊ธฐ ํ๋ค๋ค. ๐ญ
importํ๊ธฐ
head์์์ ์์ฑ
htmlํ๊ทธ์์์ ์์ฑ
๋์์ธ์์
https://www.figma.com/file/k6aekBk53MUKUwVqRHsSVx/Bugless-CSS?node-id=1%3A4
ํ ํ๋ฆฟํ์ผ
https://github.com/rohjs/bugless-101/tree/master/css-basic
box
boxmodel
์์๋ content + padding + border๊น์ง ์ด๋ค
content
๊ทธ๋ฅ ๋ด์ฉ์ด๋ค
padding
๋ด์ฉ๊ณผ ํ ๋๋ฆฌ์ฌ์ด์ ๊ณต๊ฐ์ด๋ค
border
์์์ ๊ฐ์ฅ ๋ฐ๊นฅ ํ ๋๋ฆฌ๋ค
margin
ํ ๋๋ฆฌ๋ฐ ๊ณต๊ฐ์ด๋ค
์์์ ์์์ฌ์ด์ ๊ฐ๊ฒฉ
์์ ์ค์ ์ ๋ ฌ
margin: auto;
์์๊ฐ์ ์์๋ ๊ฐ๊ฒฉ ์กฐ์ ์ margin-top์ ์ธ์ง margin-bottom์ ์ธ์ง ์ผ๊ด์ ์ผ๋ก ํ๋ ๊ฒ์ด ํท๊ฐ๋ฆฌ์ง ์์
ํฌ๊ธฐ ์ค์ ์๊ธฐํ
์์ ์๋ถํฐ ์๊ณ๋ฐฉํฅ
4๊ฐ top right bottom left
3๊ฐ top (right-botton) bottom
2๊ฐ (top-bottom) (right-bottom)
box-sizing
default๋
box-sizing: content-box
์ด๋ค์์์ ํฌ๊ธฐ๋ width(height) + padding + border ์ด๋ค
box-sizing: border-box
width์ height๊ฐ ํจ๋ฉ๊ณผ border๋ฅผ ํฌํจํ ์ด ํฌ๊ธฐ๊ฐ ๋๋ค
width์ height๋ (border๊น์ง์) ์์์ ํฌ๊ธฐ๊ฐ ๋๋ฉฐ
padding๊ณผ border์ ํฌ๊ธฐ๊ฐ ๋ฌ๋ผ์ ธ๋ ์์์ ํฌ๊ธฐ๋ ๊ณ ์ ์ด๋ฏ๋ก content์ ํฌ๊ธฐ๊ฐ ์ ๋์ ์ผ๋ก ๋ฌ๋ผ์ง๋ค
display
Block
width๋ฅผ ์ง์ ํ์ง ์์ผ๋ฉด ๋ถ๋ชจ์ width์ ์์
width๋ฅผ ์ง์ ํ๋ฉด ๋จ์ ์ ๊ณต๊ฐ์ margin์ผ๋ก ์ฑ์
๊ทธ๋ฌ๋ ๊ฐ๋ฐ๋๊ตฌ์์๋ ๊ทธ margin์ด ์ซ์๋ก ํ๊ธฐ ์๋จ
margin: 0 auto
๋ ์๊ธฐํ์ผ๋ก auto๋ก ๋ง๋ค์ด์ง margin์ ์ข์ฐ๊ฐ ๋๋์ด ๊ฐ๋๋คheight๋ฅผ ์ง์ ํ์ง ์์ผ๋ฉด ์์ ์์๋ค์ height์ ํฉ์ ์์ ์ height๋ก ๊ฐ์ง
WHPBM ์ฌ์ฉ ๊ฐ๋ฅ
Inline
๋ธ๋ก์ด ์์ญ์ด๋ผ๋ฉด ์ธ๋ผ์ธ์ ํ๋ฆ
width,height, padding(top,bottom) ,border(top,bottom) ,margin(top,bottom) ์ฌ์ฉ์ ์ด์ํ ๊ฒฐ๊ณผ๋ฅผ ์ด๋
Inline-Block
ํ๋ฆ์ ๋ฐ๋ผ๊ฐ๋ฉด์ ์์ญ์ ๊ฐ์ง
none
: ์์๋ฅผ ์์ ๋๊ฑฐ๋ ๋ง์ฐฌ๊ฐ์ง. ์์๊ฐ ์ฐจ์งํ๋ ์์น๊ฐ ์ฌ๋ผ์ง.
Float
์ฌ์ ์ ์๋ฏธ๋ "๋จ๋ค" ์ด๋ค.
์๋๋ ์ด๋ฏธ์ง์ ํ ์คํธ๋ฅผ ํจ๊ป ๋ฐฐ์นํ๊ธฐ ์ํด ๋ง๋ ์์ฑ
float๋ฅผ ํ๋ฉด ์์๋ ๋จ๊ฒ ๋๊ณ ๋จ์ง ์์ ๋ค๋ฅธ ์์๊ฐ ๊ทธ ์๋ฆฌ๋ฅผ ์ฐจ์งํ ์ ์๋ค
๋ถ๋ชจ ์์๋ Float๋ ์์์์๋ฅผ height๊ณ์ฐ์ ํฌํจ์ํค์ง ์๋๋ค
Float์ ์ฉ์ display์์ฑ์ด block๋ก ์ ์ฉ๋๋ค.
ํ์ง๋ง ๋ง์งauto๊ฐ ์๊ธฐ์ง ์๋๋ค
๊ฐ๋ณ์ ์ผ๋ก ์ปจํ ์ธ ํฌ๊ธฐ๋งํผ๋ง ํฌ๊ธฐ๋ฅผ ๊ฐ์ง๋ค.
๋ชจ๋ ์์ ์์๋ฅผ floatํ๋ฉด ๋ถ๋ชจ ์์๋ ํฌ๊ธฐ๊ฐ 0์ด ๋๋ ๊ฒ์ด๋ค
inline ์์๋ float ์์๋ฅผ ํผํด๊ฐ๋ค
๋ถ๋ชจ๊ฐ ์์์ ๋ชป ์ฐพ์ ๋ overflow: hidden์ ํ๋ฉด ๋ถ๋ชจ๊ฐ ์์์ ์ฐพ๋๋ค.
๋๋ ๋ถ๋ชจ ์์์ after์ clear ์์ฑ ์ค์
์๋ง๋ overflow๊ฐ ๋์น๋ ๋ถ๋ถ์ ๋ํ ์ฒ๋ฆฌ ์์ฑ์ด๊ธฐ ๋๋ฌธ์ ๋์น๋ ๋ถ๋ถ์ ์ฐพ๊ธฐ ์ํด width, height๋ฅผ ์ฐพ๋ ๊ฒ ๊ฐ๋ค.
๋ธ๋ก ์์ ์ํฉ์ float ์์ฑ์ ๋์ผํ ์์ ์ํฉ์ ์ํ ํญ๋ชฉ์๋ง ์ ์ฉ๋๋ฏ๋ก ์์์ ์ฐพ๊ธฐ ์ํด์๋ ์ด ์์ ์ํฉ์ ํฉ์ณ์ผ ํ๋ค. ์ด๋ฅผ ์ํด overflow ๋ณด๋ค๋ ๋ช ์์ ์ผ๋ก
display: flow-root
์ ์ฌ์ฉํ์ฌ ๋ธ๋ก ์์ ์ํฉ์ ์์ฑํ์ฌ์ผ ํ๋ค์ ์์์์ display: flow-root์ ์ ์ฉํ๋ฉด, ์ปจํ ์ด๋ ๋ด๋ถ์ ๋ชจ๋ ์์๋ ํด๋น ์ปจํ ์ด๋์ ๋ธ๋ก ์์ ์ํฉ์ ์ฐธ์ฌํ๊ฒ ๋๋ค
https://developer.mozilla.org/ko/docs/Web/CSS/CSS_Flow_Layout/Intro_to_formatting_contexts
Position
top, right , left, bottom์ผ๋ก ์์น ์ค์
static
static
๋ํดํธ ๊ฐ
relative
relative
float์ฒ๋ผ ๋ฌ๋ค
absolute
absolute
float์ฒ๋ผ ๋ฌ๋ค
์ง๋๊ฐ ์์์ด ๋๋ค. ๋ถ๋ชจ ์์๊ฐ ์ฐพ์ง ๋ชปํจ
display๊ฐ block์ผ๋ก ๋ฐ๋๋ค. ๊ธธ๋ง์ ํ์ง ๋ชปํ๋ค(auto๋ง์งx)
์กฐ์ ์์์ค position:static์ด ์๋ ์์๋ฅผ ๊ธฐ์ค ์์น๋ฅผ ์ก์
relative๋ก ์ก๋ ๊ฒ ์ข๋ค
๊ฐ์ด๋ฐ ๋ฐฐ์น
fixed
fixed
float์ฒ๋ผ ๋ฌ๋ค
viewport(ํ๋ฉด) ๋ฅผ ๊ธฐ์ค์ผ๋ก ์ก์
z-index
z์ถ์ ์์
z-index: number
์ซ์๊ฐ ๋์์๋ก ์์ ๋์ด๊ธฐ๋ณธ๊ฐ์ auto, 0์ฒ๋ผ ์ทจ๊ธ
text-align
๋ธ๋ก ์์์์ ์ธ๋ผ์ธ, ์ธ๋ผ์ธ-๋ธ๋ก ์์๋ฅผ ์ ๋ ฌ
Flexbox
์ ๋ ฌํ๊ณ ์ ํ๋ ์์๋ค์ ๋ถ๋ชจ
display:flex
display:inline-flex
flex-direction: row
๊ฐ๋ก๋ฐฉํฅflex-direction: column
์ธ๋ก๋ฐฉํฅMain axis: flex-direction๋ฐฉํฅ , Cross axis: main axis์ ์์ง๋ฐฉํฅ
flex-wrap:nowrap
์์์ ์ฌ์ด์ฆ๋ฅผ ์ค์ฌ์๋ผ๋ ํ ์ค๋ก ์ ๋ ฌflex-wrap:wrap
๊ณต๊ฐ์ด ์์ผ๋ฉด ์ฌ๋ฌ ์ค๋ก ์ ๋ ฌ๊ฐ๋ฅjustify-content:
main axis๋ฐฉํฅ์ผ๋ก ์์ ์ ๋ ฌ ๋ฐฉ๋ฒalign-items:
๊ฐ๊ฐ์ cross axis ๋ฐฉํฅ์ผ๋ก ์์ ์ ๋ ฌ ๋ฐฉ๋ฒ์ฌ๋ฌ ์ค์ด๋ฉด cross axis๊ฐ ์ฌ๋ฌ ๊ฐ๊ฐ ๋๊ธฐ ๋๋ฌธ์ ์์๋ค๊ฐ์ ์์๋ ๊ฐ๊ฒฉ์ด ์๊น
align-content:
ํ๋์ ํฐ cross axis ๋ฐฉํฅ์ผ๋ก ์์ ์ ๋ ฌ๋ฐฉ๋ฒ justify์ ๋น์ทorder: Number
์์์ ์ ๋ ฌ ์ฐ์ ์์๋ฅผ ๊ฒฐ์ . ์ซ์ ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌ๋จjustify-content align-items align-content row
์ข->์ฐ
์->์๋
์->์๋
column
์->์๋
์ข->์ฐ
์ข->์ฐ
Media Query
๋ฐ์ํ ์น๋ง๋ค๊ธฐ
Typography
px ์ ๋ ๋จ์
em rem ์๋ ๋จ์
em์ ํฐํธ ์ฌ์ด์ฆ์ ๋น์จ 1em => font-size
rem: root em html์ ์ ์ฉ๋ ํฐํธ ์ฌ์ด์ฆ ๋น์จ
1rem => html font-size
line-height
line-height
em ์ฃผ๋ก ์ฌ์ฉ ํฐํธ์ฌ์ด์ฆ์ ์๋์ ์ผ๋ก ํ๋ ๊ฒ์ด ํธํจ
๋จ์ ์๋ตํ๋ฉด em์ผ๋ก ๋ฐ์๋ค์
๊ธ์๋ ์ค๊ฐ๊ฒฉ์ ๊ฐ์ด๋ฐ ๋ฐฐ์น
๋ง์น ๊ธ์์ ์์๋์ ๋ง์ง์ด ์๊ธฐ๋ ๋๋
letter-spacing
letter-spacing
๊ธ์์ฌ์ด์ ๊ฐ๊ฒฉ
px์ em์ ์ฌ์ฉํ๋ em์ด ๋ ๋ง์ด ์ฐ์
font-family
font-family
์์ฒด์ค์
font-weight
font-weight
ํฐํธ ๊ตต๊ธฐ
100~900
400 regular 700 bold
color
color
ํ ์คํธ ์์ ์ค์
hex, rgb ,rgba
text-align
text-align
๊ธ์ ์ ๋ ฌ
text-indent
text-indent
๋ค์ฌ์ฐ๊ธฐ . ๋ง์ด๋์ค ๊ฐ๋ ๊ฐ๋ฅ
text-transform
text-transform
์ํ๋ฒณ ์๋ฌธ์ ๋๋ฌธ์ ๊ด๋ จ ์์ฑ
capitalize ์์๋ฆฌ ๋๋ฌธ์
uppercase ๋ชจ๋ ๋๋ฌธ์
lowercase ๋ชจ๋ ์๋ฌธ์
text-decoration
text-decoration
underline ๋ฐ์ค
line-through ๊ฐ์ด๋ฐ ์ค
overline ์ ์ค
a ํ๊ทธ underline์ ์์ ๊ธฐ ์ํด
text-decoration:none
font-style
normal : ๊ธฐ๋ณธ๊ฐ
italic: ๊ธฐ์ธ์
oblique: ๊ธฐ์ธ์?
em ํ๊ทธ์ ๊ธฐ๋ณธ๊ฐ์ด italic์
Webfont
google์ด ์ต๊ณ ์
https://fonts.google.com/
์ง์ ์ฌ์ฉํ๊ธฐ
head ํ๊ทธ ๋ด๋ถ์ ์ํฌํธ
๋๋ css ๋ด๋ถ์ ์ํฌํธ
Background
background-color
background-image
๊ฒฝ๋ก๋ url() ์ฌ์ฉ
background-repeat
repeat์ด ๊ธฐ๋ณธ๊ฐ, ๋ฐ๋ณตํ๊ธฐ ์ซ์ผ๋ฉด no-repeat์ฌ์ฉ
background-size
contain: ์ด๋ฏธ์ง๊ฐ ์๋ฆฌ์ง ์๊ฒ ๋ชจ๋ ๋ฃ์ => ๋น๊ณต๊ฐ ์๊น
cover: ์ด๋ฏธ์ง๊ฐ ์๋ฆฌ๋๋ผ๋ ๊ณต๊ฐ์ ๊ฝ ์ฑ์ => ๋น๊ณต๊ฐ ์์๊น
width height; ๋น์จ ๋ฌด์๊ฐ๋ฅ, auto๊ฐ๋ฅ
custom
background-position
x์ถ y์ถ ;
๊ฐ์ด๋ฐ ๋ฐฐ์น
background-position: center center;
Transition
css์์ฑ์ด ๋ฐ๋ ๋ ์ ํํจ๊ณผ๋ฅผ ์ค
transition: property timing timing-function delay;
์ฌ๋ฌ ์์ฑ์ ํ ๋ฒ์ ์ง์ ํ ๋๋ , ๋ก ๊ตฌ๋ถ
property
ํธ๋์ง์ ์ ์ ์ฉํ ์์ฑ
timing
๋ฐ๋๋ ์ง์ ์๊ฐ
timing-function
์ง์ ์๊ฐ ๊ณก์ . ์ข ๋ ๋์ ์ธ ๋๋์ ์ค
delay
ํธ๋์ง์ ์ง์ฐ
Animation
animation: animation-name duration
animation-name:
keyframes์์ ์ ์ธํ ์ ๋๋ฉ์ด์ ์ด๋ฆ
animation-duration:
์ ๋๋ฉ์ด์ ์ด ์งํ๋๋ ์๊ฐ
animation-timing-function:
์๊ฐ๊ณก์ ํจ์
animation-iteration-count:
์ ๋๋ฉ์ด์ ๋ฐ๋ณต ํ์. infinite ์์
animation-direction:
๋ฐฉํฅ. reverse=> keyframs๊ฐ to -> from์ผ๋ก ๋ฐ๋๋ก ์งํ
alternate => ๊ธฐ๋ณธ๊ฐ๊ณผ reverse๊ฐ ๋ฒ๊ฐ์ ๊ฐ๋ฉฐ ์งํ
Transform
๊ณต๊ฐ์ ๋ณํ์ํค์ง๋ง, ์ผ๋ฐ์ ์ธ ๋ฌธ์ ํ๋ฆ์ ๋ฐฉํดํ์ง ์์. ๋ฌธ์์ ๊ตฌ์กฐ์ ์์น๋ ๊ทธ๋๋ก.
none
์ด ์๋ ๊ฐ์ ์ง์ ํ๋ฉด ์๋ก์ด ์์ ๋งฅ๋ฝ์ ์์ฑํฉ๋๋ค. ์ด ๊ฒฝ์ฐ, position
์ด fixed
๊ฑฐ๋ absolute
์ธ ์์์ ์ปจํ
์ด๋ ๋ธ๋ก์ผ๋ก์ ์์ฉํฉ๋๋ค.
translate
: ์์น ์ด๋.
px, rem % ๋ฑ ๋จ์ ์ฌ์ฉ. ์ฌ๊ธฐ์ %๋ ์๊ธฐ ์์์ ํฌ๊ธฐ๋ฅผ ์๋ฏธ.
rotate
: ํ์ . ์์ -> ์๊ณ๋ฐฉํฅ . ์์ -> ๋ฐ์๊ณ๋ฐฉํฅ
martrix( scaleX, skewX, skewY, scaleY, translateX, translateY)
scale: ํฌ๊ธฐ ๋น์จ
skew: ๊ธฐ์ธ์
rotate: ํ์
translate: ์์น ์ด๋
Grid
๋ถ๋ชจ์์ display: grid
์์์์
bootstrap grid
container: grid๊ฐ ์ ์ฉ๋๋ ์ ์ฒด ์์ญ
columns: ์ธ๋ก ์ด
gutter: ์ด ์ฌ์ด์ ๋น ๊ณต๊ฐ
col-
: 576px ๋ฏธ๋ง
.col-sm-
: 576px ์ด์
.col-md-
: 768px ์ด์
.col-lg-
: 992px ์ด์
.col-xl-
: 1200px ์ด์
๊ธฐ๋ณธ ์ด์ 12
gutter๋ 30px (์ข์ฐ 15px)
Overflow
overflow: (overflow-x) (overflow-y) ;
visible
: ์์๋ฐ์ผ๋ก ๋ด์ฉ์ด ๋๊ฐ ์ ์์.
hidden
: ์์ ๋ฐ์ ๋ด์ฉ์ ์จ๊น, ์ฝ๋๋ฅผ ์ฌ์ฉํด ์คํฌ๋กค ๊ฐ๋ฅ
clip
: ์์ ๋ฐ์ ๋ด์ฉ์ ์จ๊น, ์ฝ๋๋ฅผ ์ฌ์ฉํ ์คํฌ๋กค๋ ๋ถ๊ฐ๋ฅ
scroll
: ์์ ๋ฐ์ ๋ด์ฉ์ ์จ๊น, ์ฝํ
์ธ ๊ฐ ๋์ณ์ ์๋ ธ๋์ด ์ฌ๋ถ๋ฅผ ๋ฐ์ง์ง ์๊ณ ํญ์ ์คํฌ๋กค๋ฐ ๋
ธ์ถ
auto
: ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ๊ฒฐ์ . ์ฝํ
์ธ ๊ฐ ๋์น์ง ์๋๋ค๋ฉด visible
์ ๋์ผํ๊ฒ ๋ณด์ด๋ ์๋ก์ด ๋ธ๋ก ์์ ๋ฌธ๋งฅ์ ์์ฑ๋จ. ๋ฐ์คํฌํ์ ์ฝํ
์ธ ๊ฐ ๋์น๋ฉด ์คํฌ๋กค๋ฐ๋ฅผ ์์ฑ
์์ ๋งฅ๋ฝ(stacking context)
z์ถ์ด ๊ฐ์์ผ๋ก ์๋ค๊ณ ์๊ฐํ๊ณ . html์์๋ฅผ 3์ฐจ์์ผ๋ก ๊ฐ๋ ํํ๋ค.
z-index
๊ฐ ๋์์๋ก z์ถ์์ ์์(๋ค๋ฅธ ์์๋ณด๋ค ์์) ์์นํ๋ค.์์๋งฅ๋ฝ์ด ์๋ ์์๋ ๋ถ๋ชจ ์์์ ์์ ๋งฅ๋ฝ์ ๋ฐ๋ผ๊ฐ๋ค.
ํ์ ์์๋ค๋ผ๋ฆฌ ์์๋งฅ๋ฝ์ ๊ณ ๋ ค
z-index๋ฅผ ๋ฒ์ ๋ฒํธ๋ผ๊ณ ์๊ฐํ๋ฉด ์ฌ์์ง๋ค.
z-index๊ฐ 5๋ฉด ๋ฒ์ ์ด 5, z-index๊ฐ 4์ธ ์์์์ z-index๊ฐ 1์ธ ์์๋ 4.1 ์ธ ์์ผ๋ก.
๊ทธ ํ์ ๊ทธ๋ฅ ๋ฒ์ ์ด ๋์ ๊ฒ ์์ ๊ฐ์ฅ ์์ธ ์ ์ด๋ค.
ETC
css์์ data๊ฐ ์ฌ์ฉ
ํ์ฌ ์คํฌ๋กค๊ฐ ์ถ๋ ฅ
๋ฒกํฐ ์ด๋ฏธ์ง์ ์์ฑ ์ ์ฉํ๊ธฐ
clippath์ path ๋ชจ๋ transform ์ ์ฉ๊ฐ๋ฅ
definition list
dl
ํ๊ทธ : dt์ dd๋ฅผ ๊ฐ์ผ๋คdt
: definition titledd
: definition data
Last updated