【发布时间】:2015-08-13 18:08:38
【问题描述】:
我有一个这样的 html 页面设置
<div class="row row-venue">
<div class="col-sm-12">
<h3>Venue 1</h3>
</div>
</div>
<div class="row row-venue">
<div class="col-sm-12">
<h3>Venue 2</h3>
</div>
</div>
我要做的就是让每个奇数 h3 与每个偶数颜色不同。我试过下面的代码
div.row-venue div.col-venue h3:nth-of-type(odd){
color:white;
}
div.row-venue div.col-venue h3:nth-of-type(even){
color:black;
}
甚至只是尝试过
h3:nth-of-type(odd){
color:white;
}
h3:nth-of-type(even){
color:black;
}
我似乎无法理解它,任何帮助将不胜感激
【问题讨论】:
-
谢谢,现在很有意义,以前从来没有用过,只是用来硬编码,这会节省我很多时间。赞赏
标签: html css css-selectors