κ°μ²΄λ μμ±κ³Ό μμ±κ°μ μ§ν©μ κ°μ²΄λΌκ³ ν©λλ€.
μ) h1νκ·Έλ μ¬λ¬κ°μ§ μμ±κ³Ό μμ±κ°μ κ°μ§κ³ μμ΅λλ€. λ°λΌμ h1λ νλμ κ°μ²΄μ
λλ€.
htmlλ¬Έμμ μ§μ μμ±λ κ°μ²΄λ₯Ό μ€μ‘΄κ°μ²΄λΌ νλ€λ©΄, κ°μκ°μ²΄λ htmlλ¬Έμκ° μλ cssμ λ§λ€μ΄μ§ κ°μ²΄μ
λλ€.
<ul>
<li>νλͺ©1</li>
<li>νλͺ©2</li>
<li>νλͺ©3</li>
<li>νλͺ©4</li>
</ul>
ul::before{
display: block; content: '첫λ²μ¬ μμμμΉμ κ°μκ°μ²΄';
}
ul::after{
display: block; content: 'λ§μ§λ§ μμμμΉμ κ°μκ°μ²΄';
}
ul li:first-child{
background-color: #ccc;
}
κ°μκ°μ²΄λ cssμμ λ§λ€μ μκ³ , νΉμ μμμ μμννλ‘ λ§λ€μ μμ΅λλ€.
κ°μκ°μ²΄λ νΉμ μμμ 첫λ²μ§Έ μμμμΉ, λ§μ§λ§ μμμμΉμ λ§λ€μ μμ΅λλ€.
<dl>
<dt>μ©μ΄νκ·Έ</dt>
<dd>μ€λͺ
νκ·Έ1</dd>
<dd>μ€λͺ
νκ·Έ2</dd>
<dd>μ€λͺ
νκ·Έ3</dd>
</dl>
<div class="box">
<span>Text</span>
</div>
dl{
outline: 1px solid blue;
margin-top: 40px;
}
dl dt,dd{
outline: 2px dotted deepskyblue;
height: 40px;
line-height: 40px;
}
/* dlμ 첫λ²μ§Έ μμμμΉμ κ°μκ°μ²΄λ₯Ό λ§λλλ€. */
dl::before{
display: block; content: 'dlμ κ°μ μμκ°μ²΄';
}
/* dlμ λ§μ§λ§ μμμμΉμ κ°μκ°μ²΄λ₯Ό λ§λλλ€. */
dl::after{
display: block; content: 'dlμ κ°μ μμκ°μ²΄';
}
/* dlμ 첫λ²μ§Έ μμ μμΉμ μλ ddνκ·Έλ₯Ό μ ννμΈμ.
첫λ²μ§Έ μμμ dt μ΄λ―λ‘ μ νμ μ© λΆλ₯ */
dl dd:first-child{
background-color: #ccc;
}
/* type:μμννλ₯Ό μλ―Έν©λλ€. dtνμ
μΈμ§ ddνμ
μΈμ§ μ νλ μμμ νμ
μ λ°λ¦
λλ€.
dlμ μμμμμ€ typeμ΄ ddμΈ μ²«λ²μ§Έ μμλ₯Ό μ ννμΈμ. */
dl dd:first-of-type{
background-color: #ccc;
}
.box{
margin-top: 40px;
background-color: #ccc;
line-height: 40px;
width: 120px;
text-align: center;
position: relative;
color: #000;
transition: color 0.3s;
}
.box:hover{
color: #fff;
}
.box span{
position: relative;
z-index: 2;
}
.box::after{
display: block; content: '';
/* κΈ°λ³Έκ°μ autoμ΄λ κ°μκ°μ²΄μ΄λ―λ‘ λ°°κ²½μμ μ μ©μ΄ μλμ΄ λ³΄μΈλ€. */
/* width: auto; height: auto; */
background-color: #000;
/* width: 100%;
height: 4px;
position: absolute;
bottom: 10px;
width: 0; */
width: 0; height: 40px;
position: absolute;
z-index: 1;
bottom: 0;
transition: width 0.3s;
right: 0;
}
/* κ°μκ°μ²΄μ hoverλ₯Ό μ μ©ν λμλ ν΄λμ€μ΄λ¦μ μ¨μΌν¨ */
/* .box::after:hover{
background-color: #f00;
} */
.box:hover::after{
/* background-color: #f00; */
width: 100%;
left: 0;
/* μ’νκ°μ κΈ°λ³Έκ°μ auto μ΄λ―λ‘ λ€μ λλ €μ€μΌν©λλ€. */
right: auto;
}