css 设置奇数行偶数行样式

前端开发   发布日期:2025年08月14日   浏览次数:156

.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>  

以上就是css 设置奇数行偶数行样式的详细内容,更多关于css 设置奇数行偶数行样式的资料请关注九品源码其它相关文章!