本文介绍了CSS选择表中的前4个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想选择下表中的前4列(以红色突出显示)我该怎么办?

I want to select only the first 4 columns in the table below (highlighted in red)How do I do that?

到目前为止,我已经尝试了以下方法,但这不是我想要的.

I have tried the following so far but it's not what I wanted.

table.foobardate

table.foobardate

table.foobardate> tr:not(:last-child)

table.foobardate>tr:not(:last-child)

谢谢!

推荐答案

选择器 nth-child(): -n 从头开始. +4 接下来的4.

Selector nth-child(): -n to start from begin. +4 the next 4.

td:nth-child(-n+4)

这篇关于CSS选择表中的前4个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 14:16