首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何使用CSS仅更改表格的第二列

如何使用CSS仅更改表格的第二列
EN

Stack Overflow用户
提问于 2010-03-29 08:01:26
回答 4查看 196.2K关注 0票数 142

仅使用css,我如何才能仅覆盖表的第二列的css。

我可以使用以下命令访问所有列:

.countTable table table td

我不能得到这个网页上的html来修改它,因为它不是我的网站。

谢谢。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-03-29 08:04:32

您可以像这样使用:nth-child伪类:

.countTable table table td:nth-child(2)

但请注意,这在较旧的浏览器(或IE)中不起作用,在这种情况下,您需要为单元格提供一个类或使用javascript。

票数 264
EN

Stack Overflow用户

发布于 2012-05-15 17:40:35

试试这个:

.countTable table tr td:first-child + td

您还可以重复一遍,以便设置其他列的样式:

.countTable table tr td:first-child + td + td {...} /* third column */
.countTable table tr td:first-child + td + td + td {...} /* fourth column */
.countTable table tr td:first-child + td + td + td +td {...} /* fifth column */
票数 27
EN

Stack Overflow用户

发布于 2014-01-31 18:23:43

在这个web http://quirksmode.org/css/css2/columns.html上,我发现了一种简单的方法

<table>
<col style="background-color: #6374AB; color: #ffffff" />
<col span="2" style="background-color: #07B133; color: #ffffff;" />
<tr>..
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2535112

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档