当前位置: 首页 - 编程技术 - 文章正文

table表格,隔行,格列变色

xiaoqihv
隔行变色

每隔 奇数 行变色一次

tr:nth-child(odd) { background-color: #eee;}

每隔 偶数 行变色一次

tr:nth-child(even) { background-color: #eee;}

隔列变色

每隔 奇数 行变色一次

td:nth-child(odd) { background-color: #fff065;}

每隔 偶数 行变色一次

td:nth-child(even) { background-color: #fff065;} 隔行,一半为A颜色,一半为B颜色 tr:nth-child(odd) { background-color: #eee;}tr:nth-child(odd)>td:nth-child(n+5) { background-color: #fff065;}

:nth-child() 选择器 中 n表示计数器,从 0 开始,a表示倍数,b表示偏移值

文章地址:https://wenmayi.cn/post/4845.html