【发布时间】:2014-11-12 13:20:16
【问题描述】:
我想为第 n 个子标志应用绿色
<div id="axis">
<div class="super"></div>
<div class="flag">flag 1</div><!-- I want this text to be green-->
<div class="super"></div>
<div class="flag">flag 2</div>
<div class="super"></div>
<div class="flag">flag3</div>
<div class="super"></div>
</div>
CSS:
#axis{
color:red;
}
#axis .flag:nth-of-type(1){
color:green;
}
#axis .flag:nth-child(1){
color:green;
}
我在这两种情况下都试过了,但都没有工作......
【问题讨论】:
-
索引号为
2。所以尝试使用2而不是1。 -
nt-child和nt-of-type不根据类或 ID 进行选择。 -
@MaryMelody - 你的答案是静态的
-
@JqueryKing 那你为什么要标记 jQuery?
-
jquery 用户也知道 css 为什么我被标记为 jquery
标签: html css css-selectors