我为UL的最后一个LI标签设置了一条规则:
.className li:last-child {
stuff: here;
}
Run Code Online (Sandbox Code Playgroud)
我能够设置一个规则,说:“应用此样式到最后LI标签,除非在CSS的last-child也是first-child”,也就是说,在OL唯一一个LI标签。
您可以将其与:not()选择器一起使用。
CSS伪类
:not(X)是一种功能表示法,采用简单的选择器X作为参数。它与参数未表示的元素匹配。
li:last-child:not(:first-child) {
color: red;
}Run Code Online (Sandbox Code Playgroud)
<ul>
<li>item a</li>
<li>item b</li>
<li>item c</li>
</ul>
<ul>
<li>only item</li>
</ul>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
754 次 |
| 最近记录: |