css3怎么用伪类选择器不要第一个
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css3怎么用伪类选择器不要第一个相关的知识,希望对你有一定的参考价值。
参考技术A 一、X:nth-child(n) li:nth-child(3) color: red;接下来的几个伪类选择器使用上非常类似,功能也比较接近。 :nth-child(n),用于匹配索引值为n的子元素。索引值从1开始。 X:nth-child()用法实际上有三种变化,demo的用法是最简单的,X:nth-child()更强大的用处在于奇偶匹配,明河不展开讲,有兴趣的请看《Understanding :nth-child Pseudo-class Expressions》,《CSS3 :nth-child()伪类选择器》 二、X:nth-last-child(n) li:nth-last-child(2) color: red;:nth-child(n),是从第一个开始算索引,而X:nth-last-child(n)是从最后一个开始算索引。css 怎么选择 第一个 class?
请问页面上有多个 相同名称的class ,在不同层级 ,怎么选择第一个css。比如:
<div class="demo">
……
<div class="name">
<div class="tishi">11</div>
</div>
<div class="name">
<div class="tishi">11</div>
</div>
<div class="name">
<div class="tishi">11</div>
</div>
<div class="name">
<div class="tishi">11</div>
</div>
<div class="name">
<div class="tishi">11</div>
</div>
</div>
找到demo 下面的的一个tishi
或者
.demo .tishi:nth-child(1)
或者
.demo div.tishi:first-of-type
或者
.demo div.tishi:nth-of-type(1)本回答被提问者采纳 参考技术C document.getElementsByClassName('tishi')[0] 参考技术D 你举的例子是在同一层吧,不想改tishi的话那就只能给name加编号了
以上是关于css3怎么用伪类选择器不要第一个的主要内容,如果未能解决你的问题,请参考以下文章