本文介绍了从N开始的颜色表列(td:nth-​​of-type)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想从特定列向后添加某个背景颜色。 I want to add a certain background color from a certain column onwards. Instead of having to use a css class for each column, i would rather prefer to do it otherwise if possible.我将有一个巨大的表,有几百行,而且I will have a huge table with hundreds of rows and around 25 columns and I prefer to avoid unnecessary code.目前,我使用 td:nth-​​of-type 属性来做:Currently, I am using td:nth-of-type property to do it:.demo tr.selectedRow td:nth-of-type(9),.demo tr.selectedRow td:nth-of-type(10),.demo tr.selectedRow td:nth-of-type(11),.demo tr.selectedRow td:nth-of-type(12),.demo tr.selectedRow td:nth-of-type(13),.demo tr.selectedRow td:nth-of-type(14),.demo tr.selectedRow td:nth-of-type(15),.demo tr.selectedRow td:nth-of-type(16){ background-color:#fff16b;}我想知道是否有办法减少这种情况。 I was wondering if there's any way to reduce this even more. 文档不多说... The documentation doesn't say much more...推荐答案 http://css-tricks.com/xamples/nth-child-tester/ 这个测试人员真的可以帮助。您似乎希望在9之后选择所有内容,因此请使用以下代码http://css-tricks.com/examples/nth-child-tester/ This tester can really help. It looks like you want to select everything after 9 so use the code below选择除第一个8之外的每个TD Select every TD except The First 8.demo tr.selectedRow td:nth-child(n+9) { color: red; } 这篇关于从N开始的颜色表列(td:nth-​​of-type)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-23 23:58