如代码所示,可以对列的背景色进行改变,但是修改文本对齐方式和文本颜色就不起作用了,能解决吗?
html
<table>
<colgroup>
<col />
<col />
<col class="right" />
</colgroup>
<tr>
<td>aaa</td>
<td>bbb</td>
<td>ccc</td>
</tr>
<tr>
<td>aaa</td>
<td>bbb</td>
<td>ccc</td>
</tr>
<tr>
<td>aaa</td>
<td>bbb</td>
<td>ccc</td>
</tr>
</table>
css
table {
width: 100%;
}
td {
border: 1px solid #999;
}
.right {
background: green;
color: #fff;
text-align: right;
}
IE的IE7和Quirks模式下,文本颜色和对齐方向都可以正常设置
IE8(含)以上以及其他浏览器均不支持。
CSS具体样式对col和colgroup支持的细节,我找到如下说法:
The style attribute (or induced style from id, class, etc.) only takes into account properties that sensibly apply to the column itself. That is, while each
can contain text content and thus can have attributes like text-align set, the element does not contain text and thus none of the text-level styles apply. (Block-level stuff like background-color still works.)版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。