利用css给奇数行或偶数行添加指定样式
利用css给奇数行或偶数行添加指定样式odd表示奇数行,even表示偶数行;
tr:nth-child(odd);
.table-striped > tbody > tr:nth-child(odd) {
background-color: #f9f9f9;
}
#list li:nth-of-type(odd){ background:#00ccff;}奇数行
#list li:nth-of-type(even){ background:#ffcc00;}偶数行
.list ul li:nth-child(even){ ...} //li的偶数行样式
.list ul li:nth-child(odd){ ...} //li的奇数行样式
.list ul li:nth-child(1){ top:0;} //第一个li
.list ul li:nth-child(2){ top:30px;} //第二个li
部分情况下的解决方案
<style>
.list li:nth-of-type(odd){ margin-left: 20px;}奇数行
.list li:nth-of-type(even){margin-left: 10px;}偶数行
<style>
http://www.admin365.cn/thread-44894-1-1.htmlCSS选取第几个标签元素:nth-child、first-child、last-child
页:
[1]