偽類選擇器
阿新 • • 發佈:2020-12-21
技術標籤:css
:fist-child 第一個子元素是…
:last-child 最後一個子元素是…
:nth-child(number|even|odd|倍數) 第幾個子元素是…
<!--html中-->
<div class="box">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
/*.css中*/
.box{
width:200px;
height:200px;
background-color:red;
}
.box>div:first-child{
width:100px;
height:100px;
background-color:green;
}
.box>div:last-child{
width:100px;
height:100px;
background-color:pink;
}
.box>div:nth-child(2){
width:100px;
height:100px;
background-color:block;
}