κ°μ μμλ κ°μ ν΄λμ€μ λΉμ·νλ€.
κ°μ μμ(pseudo element)
κ°μ μμλ HTML μ½λμ μ‘΄μ¬νμ§ μλ ꡬ쑰 μμμ μ€νμΌμ λΆμ¬ν μκ° μμ΅λλ€.
κ°μ μμλ κ°μ ν΄λμ€μ²λΌ λ¬Έμ λ΄μ 보μ΄μ§ μμ§λ§, 미리 μ μν μμΉμ μ½μ λλλ‘ μ½μμ΄ λμ΄μμ΅λλ€.
μ μΈ λ°©λ²μ κ°μ ν΄λμ€μ κ°κ² μ½λ‘ μ μ¬μ©νλ©°,
CSS3λΆν°λ κ°μ ν΄λμ€μ κ°μ μμλ₯Ό ꡬλΆνκΈ° μν΄ κ°μ μμμλ ::(λλΈ μ½λ‘ ) κΈ°νΈλ₯Ό μ¬μ©νκΈ°λ‘ νμ΅λλ€.
νμ§λ§ νμ λΈλΌμ°μ μμ :: λ¬Έλ²μ μ§μνμ§ μλ λ¬Έμ κ° μμΌλ―λ‘ μν©μ λ°λΌ : κΈ°νΈλ₯Ό μ¬μ©ν΄μΌ νλ€.
- :before : κ°μ₯ μμ μμλ₯Ό μ½μ / μμ λ΄μ κ°μ₯ 첫 λ²μ§Έ μμμΌλ‘ μ½μ μ΄ λλ κ².
- :after : κ°μ₯ λ€μ μμλ₯Ό μ½μ / μμ λ΄μμ κ°μ₯ λ§μ§λ§ μμμΌλ‘ μ½μ μ΄ λλ κ².
- :first-line : μμμ 첫 λ²μ§Έ μ€μ μλ ν μ€νΈ / μμμ 첫 λ²μ§Έ μ€μ μλ ν μ€νΈλ₯Ό κ°μΈλ μμκ° μ½μ μ΄ λλ€.
- :first-letter : λΈλ‘ λ 벨 μμμ 첫 λ²μ§Έ λ¬Έμ / μμ λ΄μ λΈλ‘ λ 벨 μμ μ€μ κ·Έ μμ 첫 λ²μ§Έ λ¬Έμλ₯Ό κ°μΈλ μμλ₯Ό μμ±νλ€.
λͺ¨λ κ°μ μμμ΄κΈ° λλ¬Έμ HTML ꡬ쑰μλ λνλμ§ μλλ€.
beforeμ after κ°μ μμλ μ μ΄μ λ΄μ©μ΄ μλ μνλ‘ μμ±λκΈ° λλ¬Έμ λ΄μ©μ λ£κΈ° μν΄ content μμ±μ μ΄μ©ν΄μΌ νλ€.
<head>
<title>hi</title>
<style>
p:before {
color: red;
content:"#####"
}
p:after {
color: yellow;
content: "!!!!!!!!";
}
p:first-line {
font-size: 3em;
}
p:first-letter {
color: purple;
text-decoration: underline;
}
</style>
</head>
<body>
<p>
I haven't been worried to see the dentist since I was younger.But over the last year, I got to know why people are worried to see the dentist.The first dental care was simply to fill the lower two teeth with resin filling when I felt like they hurt.One day about two months after the first dental care, while I was brushing my teeth, I chewed something weird !That was a tiny little resin tooth filling which was filled two months ago.I had to go to the dentist to be treated again and there was no extra charge for that because it has after-sales service for 1 year.But that was just a beginning. After that, I've gone there four times more.I promised myself not to go to THE dentist again.
</p>
</body>
See the Pen Untitled by HelloHailie (@hellohailie) on CodePen.
πλ μμΈν κ°μ μμπ
https://code.tutsplus.com/ko/tutorials/the-30-css-selectors-you-must-memorize--net-16048
https://developer.mozilla.org/ko/docs/Web/CSS/Pseudo-elements
'πLanguage > HTML & CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
css κ΅¬μ²΄μ± (0) | 2022.04.19 |
---|---|
visibility:hiddenμ΄λ display:noneμ μ°¨μ΄μ (0) | 2022.04.18 |
κ°μ ν΄λμ€ (pseudo class) first-child (0) | 2022.04.17 |
CSS λΆλͺ¨μ μμ, μ‘°μ, νμ κ΄κ³ μ 리 (0) | 2022.04.17 |
CSS μμ± μ νμμ λν΄ κ³΅λΆν΄λ³΄μ (0) | 2022.04.17 |