我想自定义每列的第一行。我尝试了许多HTML和CSS技巧,但不适用于我。
所附图片将进一步说明。我在WordPress中使用表格插件,因此无法将JavaScript或添加id
到单个列中。
试试这个:
table > * > tr > td:first-child{
/* css styles */
}
在此处*
代替thead
和tbody
。
但是有时使用*
性能会很昂贵..因此,如果您关心性能,请执行以下操作:
table > thead > tr > td:first-child, table > tbody > tr > td:first-child{
/* css styles */
}
我想在这里分享一个技巧,不需要 :first-child
table > thead > tr > td + td, table > tbody > tr > td{
/* normal styles */
}
table > thead > tr > td, table > tbody > tr > td{
/* first-child styles */
}
上面的技巧每次都对我有用,因为第一个孩子不是任何其他td元素的同胞:)。我的意思是在第一个孩子元素之上没有其他元素。但是我更喜欢使用:first-child
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句