์ฝ๋๋ฅผ ์งค ๋ BEM ๋ฐฉ๋ฒ๋ก ์ ์ฌ์ฉํ์!!
p { font-size: 15px; color: yellow; }
p : selector
{} : declaration block
font-size: 15px; : declaration
font-size : property, 14px : value
๋ด๋ถ : html file ๋ด์ style ํ๊ทธ ์ด์ฉ
์ธ๋ถ : css file ๋ง๋ค๊ณ html file ์์ link ํ๊ทธ ์ด์ฉ
ํ๋์ html file์ ์ฌ๋ฌ๊ฐ์ css file ์ฐ๊ฒฐ ๊ฐ๋ฅ. ์ด ๊ฒฝ์ฐ, html file ๋ด์ link tag๋ฅผ ์ด๋ค๊ฑธ ๋จผ์ ์ฐ๋์ ๋ฐ๋ผ ์ฐ์ ์์ ๋ถ์ฌ (declaration ์์ !important ๋ฅผ ์จ์ ์ฐ์ ์์๋ฅผ ์ค ์ ์์ง๋ง... ์ฐ์ง๋ง์)
<h1 style="color:blue; font-weight:bold;> </h1> /* html tag ์์ style tag๋ฅผ ๋ฃ๋ ๊ฒ */
!important >>> inline > ๋ด๋ถ css > ์ธ๋ถ css ์์ด๊ณ , ๋ด์ธ๋ถ CSS ์์๋ #id > .class, :class > tag > inherit ์์ผ๋ก ์ฐ์ ์์๊ฐ ๊ฒฐ์ ๋๋ค.
<style> @import url(ํ์ผ์ด๋ฆ.css); @import url("ํ์ผ์ด๋ฆ.css"); @import url("./ํ์ผ์ด๋ฆ.css"); @import "ํ์ผ์ด๋ฆ.css"; </style> /* import ๋ฌธ์ ํ์ฉํ์ฌ ๋ค๋ฅธ css ํ์ผ์ ์ฐ๊ฒฐํ ์ ์๋ค. */
์ค๋ฌด์์๋ CSS style์ ์ ์ฉํ๊ธฐ ์ํด์ default style์ ์ ๋ถ ์ด๊ธฐํํ๊ณ ์ฌ์ฉํ๋ค. CDN์ผ๋ก ํ๊ธฐ๋ ํ๋๋ฐ ์ง์ ํ๋ ํธ์ด ๋ซ๋ค!
input, button ๋ถ๋ชจ ์คํ์ผ ์๋จน๋๊ฒ default๊ฐ inherit ์ผ๋ก ์๋์ด ์์ด์ ๊ทธ๋ผ... reset์ inherit์ผ๋ก ์ค์ ํ๋ฉด ๋๋ค.
button { background: none; color: inherit; border: none; padding: 0; font: inherit; cursor: pointer; outline: inherit; }
์น ์ ๊ทผ์ฑ ๊ณ ๋ ค์ ๊ธ์๋ฅผ ์จ๊ธฐ๋ 4๊ฐ์ง ๋ฐฉ๋ฒ
display: none
์ผ๋ก ์จ๊ธฐ๋ฉด screen reader์ ์์ฝํ๋ค..sr-only { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; } .sr-only { position: absolute; overflow: hidden; width: 1px; height: 1px; clip: rect(1px, 1px, 1px, 1px); } .a11y-hidden { position: absolute; overflow: hidden; clip: rect(0,0,0,0); width: 1px; height: 1px; margin: -1px; }
์น ์ ๊ทผ์ฑ ๊ณ ๋ คํด์ ์จ๊ธฐ๊ธฐ ๋ค๋ฅธ ๋ฐฉ๋ฒ
skip navigation ๋ง๋ค๊ธฐ.
<div class="nav-skip"> <a href="#cont-nav">์ํ ์ ๋ณด ๋ชฉ๋ก ๋ฐ๋ก๊ฐ๊ธฐ</a> <a href="#cont-company">ํ์ฌ ์ ๋ณด ๋ชฉ๋ก ๋ฐ๋ก๊ฐ๊ธฐ</a> </div>
.nav-skip a { position: absolute; top: -200px; left: 0; width: 160px; border: 1px solid #fff; color: #fff; background: #333; text-align: center; } .nav-skip a:active, .nav-skip a:focus { top: 0; }
์ ๊ทผ์ฑ์ ์ํด ์์ด์ฝ ๊ฐ์ ๊ฐ์์์์ focus ๋์ ๋ outline ๋ง๋ค์ด์ฃผ์
/* ์ ๊ทผ์ฑ */ .form-login .inp-hold:focus + .labl-hold::before { outline: 2px solid black; outline-offset: 5px; }
์ด๋ค ๋ธ๋ผ์ฐ์ ์์ ์ด๋ ๊ฒ ๋ณด์ด๋ฉด ์ข๊ฒ ๋ค. -> tag๋ฅผ ๋ณ๊ฒฝํด์ค๋ค๋์ง
* : ์ ์ฒด ์ ํ์ tag : ํด๋น ํ๊ทธ ์ ํ์ .class : class ์ ํ์ #id : id ์ ํ์
h1, h2, h3 { /* ์ฌ๋ฌ๊ฐ ์ ํ ๊ฐ๋ฅ */ } section ul { /* ํ์ ์ ํ์ : section ํ์์ ์๋ ๋ชจ๋ ul ์ ํ*/ } section > ul { /* ์์ ์ ํ์ : section ๋ฐ๋ก ๋ฐ๋จ๊ณ์ ์๋ ul๋ง ์ ํ */ } h1 ~ ul { /* ์ผ๋ฐ ํ์ ์ ํ์ : h1๊ณผ ๊ฐ์ ์์น์ ์๋ ๋ชจ๋ ul ์ ํ */ } h1 + ul { /* ์ธ์ ํ์ ์ ํ์ : h1๊ณผ ๊ฐ์ ์์น์ ์๊ณ ๋ฐ๋ก ํ์์ ์๋ ul ํ๋๋ง ์ ํ */ } h1 + ul + ul { /* h1 ํ์ ์ค์ h1 ๋ฐ์๋ฐ์ 2๋ฒ์งธ ul์ด ์ ํ๋จ. ์ด๋ ๊ฒ ์ ์ฐ์ง ์์.*/ }
ํท๊ฐ๋ฆฌ๋ ์ ํ์
.one .two { /* .one ๋ฐ์์๋ .two (3๋ฒ) */ color: blue; } .one.two { /* class one two ๋ค ๊ฐ์ง ์ (2๋ฒ) */ color: red; }
<div class="one">hello world</div> <div class="one two">hello world</div> <div id="one two">hello world</div> <!-- id๋ฅผ ์ค์ฒฉํ๋ฉด one ๋ง ์ ์ฉ๋จ --> <div class="one"> <div class="two">hello world</div> </div>
a[href] { /* a์ href ์์ฑ์ด ์๋ ๊ฒ */ } input[type="text"] { /* input type ์ด text์ธ ๊ฒ */ a[href~="word"] { /* word๋ฅผ ํฌํจํ๋ href ๊ฐ์ ๊ฐ์ง๋ ๊ฒ๋ง (๋จ์ด๊ธฐ์ค์ด๋ผ words๊ฐ word ๋ฅผ ํฌํจํ๋ค๊ณ ์ก์๋ด์ง ๋ชปํจ) */} a[href*="word"] { /* word๋ฅผ ํฌํจํ๋ href ๊ฐ์ ๊ฐ์ง๋ ๊ฒ๋ง (๋ฌธ์์ด ๊ธฐ์ค์ด๋ผ ์์ ๋ค๋ฅด๊ฒ words๋ ์ก์๋.) */ } a[href^="http"] { /* http๋ก ์์ํ๋ ๊ฒ๋ง */} a[href$="com"] { /* com์ผ๋ก ๋๋๋ ๊ฒ๋ง */} a[href|="http"] { /* http์ ์ผ์นํ๊ฑฐ๋, http๋ก ์ํ๋ ๊ฒ๋ง. */ } }
023.html ์ ๋ณด๋ฉด ๋ ์ดํด๊ฐ ๊ฐ๋ค!
ํด๋์ค๊ฐ ์๋ ์์์ ํด๋์ค๋ฅผ ์ฝ์ ํ๋ค. ํด๋์ค๋ฅผ ์ค์ ํด๊ฒฐํ ์๋ ์์ง๋ง :๋ฅผ ์ฐ๋๊ฒ ํธํ ๊ฒฝ์ฐ์ ์ฌ์ฉ.
.foo:nth-child(odd) { /* .foo ์ค ํ์๋ฒ์งธ๋ง. 2n+1๋ก ๋ฃ์ด๋ ๋จ. */ } input:hover { } input:focus { } input:active { }
๋งํฌ์ ์๋ ์์๋ฅผ ์ฝ์ ํ๋ค. ์ค์ ์ฌ์ดํธ์์ ์๋ณด์ด๋ ์์๋ฅผ ๋ฃ๊ณ ์ถ์ ๋ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง๋ค.
ํ์์๋ html๋ฌธ์ ์ต๋ํ ๋ฃ์ง ๋ง์๋ ์๋์์ ๋ง๋ค์ด์ง!
p::after { content: 'cm' } /* p ๋ค์ cm์ ์ฝ์ : cm๊ฐ ๋งํฌ์ ๋์ด ์๋๊ฒ ์๋๋ฐ ์ฝ์ ๋๋ค. ์ด ๋ถ๋ถ์ ์ ํ ์๋จ */
inline > ๋ด๋ถ > ์ธ๋ถ ์
id > class > tag ์์ผ๋ก style ์ ์ฉ์ด ๋๋ค.
์ ์ ๊ณ์ฐ - id: 100์ , class & ๊ฐ์ ํด๋์ค ์ ํ์ : 10์ , ์์, ๊ฐ์ ์์ ์ ํ์: 1์
์ ์๊ฐ ๊ฐ์๋ id ๋ค์ด๊ฐ๊ฒ ์ฐ์ !
.main div:nth-child(4) {
class 10์ + div 1์ + :nth-child (๊ฐ์ ํด๋์ค ์ ํ์) 10์ = 21์
}
ํ ํ๋ฆฟ์ ์ฐ๊ฑฐ๋, ์ฌ๋ฌ ์ฌ๋์ด ํ์ ํ ๋ ๋ด๊ฐ ์๋ํ ๋๋ก ์คํ์ผ ์์ ์ด ๋์ง ์๋ ๊ฒฝ์ฐ๊ฐ ์๊ธฐ ๋๋ฌธ์ ๋ค๋ฅธ ์์๋ค์ ๊ณ ๋ คํด์ผ ํ๋ค.
CSS ์ฐ์ต ํด๋ณด๋ฉด ํท๊ฐ๋ฆฌ๋ ๊ฐ๋ ๋ค์ ์ก์ ์ ์๋ค!!
์ ๋ ํฌ๊ธฐ : px, pt, in, cm, mm
- html ๊ธฐ๋ณธ ํฐํธ : 16px
- px : animation ํ ๋ ๊ณ ์ ํฌ๊ธฐ๋ ๋ง์ด ์ด๋ค.
๊ฐ๋ณ ํฌ๊ธฐ : %, em, rem, vw, vh, vmin, vmax, ex (๋ถ๋ชจ๋ง ๋ฐ๊ฟ์ฃผ๋ฉด ๋๋จธ์ง๋ ๋ค ๋ฐ๋. ๋ค ๋ง๋ค๊ณ ๋ณ๊ฒฝํ๊ธฐ ํธํ๋ค.)
- % : 100% - ๋ถ๋ชจ์ 100%
- em : 1em - ๋ถ๋ชจ์ 1๋ฐฐ. ๊ทธ๋ฌ๋ ์ค์ฒฉ๋๋ ๊ฒฝ์ฐ ๊ณ์ฐํ๊ธฐ ๊ท์ฐฎ๋ค.
- rem : 1rem - root์ 1๋ฐฐ
- vw, vh: ๋ณด์ฌ์ง๋ ํ๋ฉด ๊ธฐ์ค
width์ border๋ ํฌํจ๋์ง ์๋๋ค. border-box๋ฅผ ์ฐ๋ฉด ํฌํจ๋จ.
+) ์์์ ๋์ด๋ฅผ ์ฌ๋งํ๋ฉด ์ง์ ํ์ง ๋ง์...! padding์ ์ด์ฉํด์ ์์ contents์ ๋์ด์ ์ข ์๋๋๋ก ํ์.
border : ํ ๋๋ฆฌ
border: border-width border-style border-color | initial | inherit
border-radius : 4๋ฉด ๋ชจ๋ ๋ฅ๊ธ๋ ค์ง.
border-top-left-radius: ์ผ์ชฝ ์๋ง ๋ฅ๊ธ๋ ค์ง.
margin : content ์์ญ ๋ฐ๊นฅ
padding : content ์์ญ์ ํฌํจ/* top right bottom left ์์ผ๋ก ๋ค์ด๊ฐ. iOS๋ ๋ฐ๋ */ padding: 10px 20px 30px 40px; /* ์ ์ฐ ํ ์ข */ padding: 10px 20px 30px; /* ์, ์ข์ฐ, ํ */ padding: 10px 20px; /* ์ํ, ์ข์ฐ */ padding: 10px;
margin ๋ณํฉ(collapsing) ํ์
- ์์ ์์ margin-bottom์ด๋ ์๋ ์์ marign-top ์ค ํฐ ์ชฝ์ผ๋ก ํฉ์ณ์ง๋ค.
- child์ margin-top, margin-bottom ์ด parent์ ๋์ด์ ์ํฅ์ ๋ฏธ์น์ง ์์์ child๊ฐ parent ์์ญ์ ๋ฐ์ด ๋์ด๋ฒ๋ฆฐ๋ค.
-> ๋ถ๋ชจ overflow, inline-block, border ์กฐ์ ์ผ๋ก ํด๊ฒฐํด๋ณด์.- ์ผ๋ถ๋ฌ ์๋ํด์ ๋ณํฉ ํ์์ ์ฌ์ฉํ๊ธฐ๋ ํ๋ค.
h1, p ๊ฐ์ ์์์ margin์ 0์ ์ค๋ ํ์ด์ง ์์์ ์ ๋ฑ ๋ถ์ง ์๋๋ค. -> body ์๋ ๊ธฐ๋ณธ์ ์ผ๋ก margin ๊ฐ์ ์์ฑ์ด ๋ค์ด๊ฐ์์ด์ ๊ทธ๋ ๋ค.
#2.5 CSS ์์ฑ ์๋ ์ ๋ฆฌ๋์ด ์๋ค.
๋ผ์ด์ธ ๊ทธ๋ฆฌ๊ธฐ tutorial ์ด๋ฐ๊ฑธ ํด๋ณด๋ฉด ์ค๋ ฅ์ด ๋ง์ด ๋๋ค!!
- block : ํ๋ฉด์ ๊ฐ๋ก ์์ญ๋งํผ ์์ญ ์ฐจ์ง. ์ค ๋ฐ๋.
- inline : ์๊ธฐ ์์๋งํผ์ ๋์ด๋ง ์ฐจ์งํ๋ค. ์ค๋ฐ๊ฟ ๋์ง ์์. width์ height, margin-top, margin-bottom ์ ์ค ์ ์๋ค.
- inline-block : inline ์ฒ๋ผ ํ ์ค์ ๊ฐ๋ก๋ก ๋ถ๋๋ค. ๊ทธ๋ฌ๋, width, height, margin์ ๋ค ์ค ์ ์๋ค. ์์ฒด์ ์ผ๋ก margin์ ๊ฐ์ง๊ณ ์๋ค.
- contents : ์์ด๋ ๋ค์ ์ฝํ ์ธ ๋ถ์ธ๋ค.
- flex : ํ, ์ด์ ๋ค๋ฃจ๋ 1์ฐจ์ ๋ ์ด์์.
- grid : 2์ฐจ์ ๋ ์ด์์.
inline vs inline-block
<!-- ์๋
ํ์ธ์ ์๋
ํ์ธ์ ์๋
ํ์ธ์ -->
<div>์๋
ํ์ธ์</div>
<div>์๋
ํ์ธ์</div>
<div>์๋
ํ์ธ์</div>
<!-- ์๋
ํ์ธ์์๋
ํ์ธ์์๋
ํ์ธ์ -->
<div>์๋
ํ์ธ์</div><div>์๋
ํ์ธ์</div><div>์๋
ํ์ธ์</div>
+) ์ด๋ฏธ์ง๋ inline ์ด๋ผ์ text ์ฒ๋ผ ๋ฏธ๋ฌ๋ฏธ๋ฌํ ๊ฐ๊ฒฉ์ด ์๊ธฐ๋๋ฐ baseline์ด ์์ด์ ์๊ธฐ๋ ํ์์ผ๋ก display: block; width: 100%;
๋ก ์ฌ์ฉํ๊ฑฐ๋ vertical-align: top;
์ ์ฃผ๋ฉด ํด๊ฒฐํ ์ ์๋ค. img, vertical-align
overflow : visible, hidden, scroll;
overflow-x, overflow-y ๋ก ๋ฐ๋ก ์ง์ ๊ฐ๋ฅ.
visible : ๊ธฐ๋ณธ. content ์๋ฅด์ง ์์.
hidden : ํฌ๊ธฐ์ ๋ง์ถฐ์ ์๋ฆ.
scroll : ํฌ๊ธฐ์ ๋ง๊ฒ ์๋ฅด๋๋ฐ ์คํฌ๋กคํด์ ๋ณผ ์ ์๊ฒ.
color, image, repeat, position, ...
img์ background-image์ ๋ค๋ฅธ ์ : ์ ์ ์ด๋ฏธ์ง(ํค๋์ ๋ค์ด๊ฐ๋ ์ด๋ฏธ์ง์ฒ๋ผ ๋ฐ๋์ง ์๋)๋ background ๋์ ์ด๋ฏธ์ง(ํฌ๊ธฐ๊ฐ ๋ณํ๊ฑฐ๋ ์์น๊ฐ ๋ณํจ)๋ img
size, weight, family ...
opacity : ํฌ๋ช ๋ 0~1 ์ฌ์ด์ ๊ฐ.
color : name, code๋ก ์ฌ์ฉ ๊ฐ๋ฅ.background: #999; /* #999999์ ๊ฐ์ */ background: rgba(234, 23, 324, 1);
tag๋ ๊ฒฐ๊ตญ ์ด๋ค <์ด๋ฆ></์ด๋ฆ>์ ์ฃผ๊ณ ์ถ์ ์์ฑ์ ๋ฌถ์ด๋ ๊ฒ์ด๋ฏ๋ก, ์ง์ ์ ์ธํด์ ์ฌ์ฉํด๋ ๋๋ค. ํ์ง๋ง sementic ๊ตฌ์กฐ๋ฅผ ์ํด ์ง์ํ๋ค.
font๋ ํ๋ฉด ์ฝ๋๋ฅผ ์ง๋ฉด์ ๋๋๊ฑด๋ฐ, iOS๋ ๋ฌธ๋ฒ์ ๋ค๋ฅด์ง๋ง ์๋นํ ๋น์ทํ๋ค๋ ์ ์ ๋๊ผ๋ค. ๊ทธ๋๋ ์ข์ ์ ์ ๋ญ๊ฐ ์๋ชป ์ง๋ฉด ์ฃฝ์ด๋ฒ๋ฆฌ๋ iOS๋ ๋ค๋ฅด๊ฒ html์ ๋ญ๊ฐ ์๋ชป๋ ํ๋ฉด์ด ๋์จ๋ค๋ ์ !
์ขํ๋ฅผ ์ง์ ํ์ง ์์ผ๋ฉด ์์ ์ด ์๋ ๋ ์ผํ๋ ์์น์ ๋ฌ๋ค!!
+) position์ ์ค ๋ ๊ฐ์ฅ ๋ฐ๊นฅ์ ์๋ ์์์ ์ฃผ์. ํนํ button>img, a>img ์ ๊ฒฝ์ฐ button์ด๋ a์ ์ค์ผํจ. ๊ธฐ๋ฅ์๋ ๋ฌธ์ ๊ฐ ์์ผ๋ focusing์ด ์๋ผ์ ์ ๊ทผ์ฑ์ ๋ฌธ์ ๊ฐ ์๊น.
+) inline ์์์ position์ ์ฃผ๋ฉด display: block ์ด ๋๋ค. ๋ ๋ฒ ๋ช ์ํ ํ์ ์๋ค.
+) ๋์ด, ๋์ด ๋ชจ๋ฅผ ๋๋ transform: translate(-50%, -50%);
์ค์์ผ๋ก ๋ก๊ธธ ์ ์๋ค!
default ๋ก ์ฃผ์ด์ง๋ ๊ฐ.
normal flow : static ์ ์คฌ์๋ ๋ํ๋๋ ์์ฐ์ค๋ฌ์ด layout
relative : ์๋ ์์ ์ด ์์ด์ผ ํ๋ ์์น์ relative.
absolute ์ ๊ธฐ์ค์ relative
๋ถ๋ชจ์ relative ๊ฐ ์์ผ๋ฉด ๊ทธ๊ฒ๋ณด๋ค ์์์ ์๋ fixed, relative, absolute ๊ธฐ์ค.
์์์ ์์ relative๊ฐ ์๋ค๋ฉด? body ๊ธฐ์ค.
top : ์๋๋ก ๊ฐ์ผ ์์(+), bottom : ์(+), left : ์ค๋ฅธ์ชฝ(+), right : ์ผ์ชฝ(+)
iOS์ ๋ค๋ฅด๋ค!
normal flow์ ์๋ ๊ฒ๋ค์ absolute๋ฅผ ์์๋ณผ ์ ์์ด์ ๊ฒน์น๋ค.
๋
ผ๋ฆฌ์ markup ์์ ๋๋ฌธ์ ๋๋ณด๊ธฐ ๋ฒํผ ๊ฐ์ ๊ฒฝ์ฐ๋ float๊ฐ ์๋๋ผ absolute๋ฅผ ์ฌ์ฉํด์ ๋ถ์ธ๋ค.
ํ๋ฉด ์ผ์ชฝ ์๋จ์ (0, 0)์ผ๋ก ํ๋ ์ขํ๊ณ๋ก ๊ณ ์
+) fixed ๋ ํ๋ฉด ๊ธฐ์ค์ผ๋ก ๊ทธ๋ฅ ๊ณ ์ , sticky๋ ์คํฌ๋กค ๋ฐ์ค ์์์ ๊ณ ์ . Sticky๋ ๋ฌธ์์ ํ๋ฆ ๊ณ ์ ํ๊ฒ ๋๋ค.
ํ๋กํ ๋ฒํผ ๊ฐ์ ๊ณณ์ ์ฌ์ฉํจ.
๋ถ๋ชจ ์ค์ ๊ฐ์ฅ ๊ฐ๊น์ด ์คํฌ๋กค ๋ ์์์ ๋ถ์.
์คํฌ๋กค ์์๊ฐ ๋ณธ์ธ์ offset์ ๋์ด๊ฐ ๋๋ถํฐ ๋ถ๊ณ , ์คํฌ๋กค ๋๋ ๋ถ๋ชจ ์์ญ์ด ๋๋๋ฉด ์๊ธฐ ์๋ ์์น๋ก ์ด๋./* ๋์จ์ง ์ผ๋ง ์๋ผ์ prefix ๋ถ์ฌ์ผํจ */ h2 { position: -webkit-sticky; position: sticky; top: 0; /* ์๊ณ์ */ background-color: yellowgreen; }
๊ฐ์ด ํด์๋ก ํ๋ฉด ์์ชฝ์ ๋ํ๋จ. like ppt ๋งจ ์์ผ๋ก
๊ธฐ๋ณธ๊ฐ์ ๋ถ๋ชจ์ z-index (html์ z-index๋ 0)
+) modal dim ์ฒ๋ฆฌํ ๋๋ z-index๋ฅผ ์ค์ ๋ค์ ๊ฒ์ ํด๋ฆญํ์ง ๋ชปํ๊ฒ ํ์.
์์ง์ผ ๋์์ CSS์
์์ง์ผ ๋์ { transition: all ์ดs; } ์์ง์ผ ๋์:hover { color: white (์๋ ๋ฐ๊ฟ ์ ์๋ค); transform: ์์ง์ rotate(20 deg), translate(10px, 20px), scale(2) ...; }
+) CSS๋ฅผ ๋ง์คํฐํ๊ณ ์ถ๋ค๋ฉด CSS ์๋ฒฝ ๊ฐ์ด๋