๋ฐ์ํ
[HTML&CSS] Combinator, Pseudo selectors - 2
( UPDATE 2023 - 05 - 27 )
combinator, pseudo selectors
div span
div ์์ span
div > span
div ์์ ์ง๊ณ span
p + span
p ‘๋ฐ๋ก ๋ค์’์ผ๋ก ์ค๋ span
p ~ span
p ‘๋ค์’ ์ผ๋ก ์ค๋ span ( ๋ฐ๋ก ๋ค์ ์ค์ง ์์ ๋ ์)
input:required
input์ required ์๋ ๊ฒฝ์ฐ๋ง ์ ์ฉ
input[type=“password”]
input์ password ํ์ ๋ง ์ ์ฉ
input[placeholder=“username”]
placeholder๊ฐ username ์ธ ๊ฒฝ์ฐ๋ง ์ ์ฉ
input[placeholder~=“name”]
placeholder์ name์ด ๋ค์ด๊ฐ ๊ฒฝ์ฐ๋ง ์ ์ฉ
input[placeholder$=“name”]
placeholder์ ๋์ name์ด ๋ค์ด๊ฐ ๊ฒฝ์ฐ๋ง ์ ์ฉ
input[placeholder^=“name”]
placeholder์ ์ฒ์์ name์ด ๋ค์ด๊ฐ ๊ฒฝ์ฐ๋ง ์ ์ฉ
~
span์ด p์ ํ์ ์ธ๋ฐ, ๋ฐ๋ก ๋ค์ ์ค์ง ์์ ๋ ์ธ ์ ์๋ค.
Attribute selectors
ํน์ฑ ์ ํ์
~=
name์ ํฌํจํ๊ณ ์๋ค๋ ์๋ฏธ๊ฐ ๋๋ ๊ฒ์ด๋ค.
- a[href$=".org"] → '$='๋ '.org'๋ก ๋๋๋ ๋ชจ๋ anchor๋ฅผ ์ ํํ ์ ์๋ค.
- ๊ทธ๋ฅ input๊ณผ required input์ด ์๋ค๋ฉด, input:required{}๋ฅผ ํตํด์, required input์๋ง ์์ฑ์ ์ ์ฉ์ํฌ ์ ์๋ค.
- input{} ์ ํตํด, [input ์ด๋ฆ]์ ํด๋นํ๋ input ์์ฑ์ ๋ฐ๋ก ์ค ์ ์๋ค.
- ์ฌ๊ธฐ์, input[placeholder="First name"]์ First name์๋ง ์์ฑ์ ์ฃผ์ง๋ง, input[placeholder~="name"]์ name์ด ๋ค์ด๊ฐ๋ ๋ชจ๋ input์ ์์ฑ์ ๋ถ์ฌํ ์ ์๋ค.
- attribute selectors๋ฅผ ์ด์ฉํ๋ฉด, class๋ฅผ ์ง์ ํ ํ์ ์์ด CSS๋ง์ผ๋ก ๊ฐ๊ฐ์ ์์ฑ์ ๋ถ์ฌํด์ค ์ ์๋ค.
์ถ์ฒ
๋ ธ๋ง๋ ์ฝ๋ ์ฝ์ฝ์ํก ํด๋ก ์ฝ๋ฉ
๋ฐ์ํ