* = ์ ์ฒด ์ ํ์
img, button, etc.
Selector List
,(์ผํ๋ก) ์ฌ๋ฌ๊ฐ ๊ฐ๋ฅ
h1,h2 { color : blue;}
<button id="signup">Sign Up</button> -html
#signup {background-color: black;} - css
id - ๋์ด์ฐ๊ธฐ x
์งง์ ๊ธธ์ด
์๋ฏธ ํฌํจ
์ค๋ณต ์ฌ์ฉ x (ํ์ผ์์์ ํ๋๋ง ์ฌ์ฉ ํ ๊ฒ)
<span class="tag">funny</span>
.tag { background-color: #e63946;
color: #f1faee;
font-size: 16px;}
์ ํ์ด ๊ฐ์ง ์์๋ ๋จ class๋ฅผ ์ด์ฉํ๋ฉด ๊ณตํต์ ์ผ๋ก ์์ ์ ์ฉ ๊ฐ๋ฅ
์ฐ์ ์์๋ก class selector ์ ์ฉ
<li class="done">Walk Chickens</li>
<li>Clean Out Coop</li>
<li class="done">Collect Chicken Eggs</li>
<li>Incubate Chicken Eggs</li>
<li>Hatch New Chickens!</li>
.done{color:grey;}
li{color:blue;}
header a {font-size:30px; color:teal;}
#dislikes a {color:red; font-weight:bold;}
๊ณต๋ฐฑ(๋์ด์ฐ๊ธฐ)๊ฐ ์ค์ํจ
<nav>
<label for="search">Search</label>
<input type="text" placeholder="search" id="search">
<input type="password" placeholder="password">
<button>Log In</button>
<button id="signup">Sign Up</button>
</nav>
input + button { background-color: pink;}
์ค๋ช
: input ๋ค์์์ค๋ button์ ์ ํํจ
<footer>
<nav>
<ul>
<li>
<a href="#home">Home</a>
</li>
<li>
<a href="#about">About</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
<li>
<a href="www.google.com">Google</a>
</li>
</ul>
</nav>
<a href="#license">Content is available under these licenses.</a>
</footer>
footer>a {color: red;}
footer ํ๋จ๊ณ ์๋์ธ <a> tag์๋ง ์ ์ฉ
footer >ul >li >a ์๋ ์ ์ฉ์ด ์๋จ
+)adjicent selector์ direct child ๋ ๋ง์ด ์ฐ์ด์ง๋ ์์
<input type="password" placeholder="password">
input [type="password"] { color: greenyellow;}
<a href="www.google.com">Google</a>
a[href *="google"] { color: magenta;}
" *= "
:hover = ์ปค์๋ฅผ ์ฌ๋ ค๋๋ฉด ํน์ ํจ๊ณผ ๋ฐ์
button:hover { color: aqua;}
:active = ํ์ฑํ๋์์ ๋ ๋ค๋ฅธ ์์ด๋ ์ํ๋ฅผ ๋ถ์ฌ (ex)๋ฒํผ์ ํด๋ฆญํ๊ณ ์์ผ๋ฉด)
button:active {color: yellowgreen;}
:checkd = radio type or checkbox type ์์ ์ฒดํฌ๊ฐ ๋์ด์์ ๋ํ๋๋ ๋ค๋ฅธ ์์ด๋ ์ํ๋ฅผ ๋ถ์ฌ
:nth-of-type = ๋์ผํ ์ ํ์์ ์์น๋ฅผ ๊ธฐ์ค์ผ๋ก ์ ์ฉ์ํด
.post:nth-of-type(3n) { background-color: wheat;}
๋ณดํต :: ๋ก ์๋
h2::first-letter { font-size: 50px;}
first-line ๋ฑ๋ฑ ์ฌ๋ฌ ์ต์
์ด ์์
- The Cascade
code์์์ ๋ฐ๋ผ ์์์๋ถํฐ ์๋๋ก ์ ์ฉ๋จ
- Specificity
Inline Styles > ID > CLASS > ELEMENT
์ถฉ๋์ด ์์ ๋๋ ์ ์ ํฉ์ฐ์ผ๋ก ๊ฒฐ์ ๋จ
specificity calculator ์ฌ์ฉ ๊ฐ๋ฅ
- chrome ๊ฐ๋ฐ์ ๋๊ตฌ๋ ์ ์ฉํ๋ค
- Inline Styles
์ฌ์ฉ๋๊ฐ ๋จ์ด์ง html ์ฝ๋์์ ์ ๋ค ๋ณด๋ ์ฝ๋ ๊ฐ๋
์ฑ๊ณผ ์ค์ฉ์ฑ์ด ๋จ์ด์ง
- !important
specificity๋ฅผ ๋์ด์๋ ๋ช
์์ ์ง์
- Inheritance
color : inherite
์ด๋ฐ์์ผ๋ก ์ด์ฉ ๊ฐ๋ฅ
- ๊ฐ๋ฐ์๋๊ตฌ - elments๋ฅผ ๋ค์ด๊ฐ๋ฉด ๋ฌด์์ผ๋ก๋ถํฐ ์์๋ฐ์๋์ง ๋ฑ์ ์ ์ ์์