表样式 - col类应该重写超过td类..如何? [英] Table Styling - col class should override over td class.. How?

查看:162
本文介绍了表样式 - col类应该重写超过td类..如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看此小提琴:



http:// jsfiddle。 net / uqJHf /



我设置第一列显示为红色背景。



然而,奇/偶样式正在覆盖它。即使添加了!重要的;



有没有办法我可以得到这个固定? (无需向

中添加类

  tr.row_odd td {
background:#efefef;
}
tr.row_even td {
background:green;
}
.col1 {background:red!important;}

< table>
< col class =col1>< / col>
< tr class =row_odd>< td> test< / td>< td> test< / td> < / tr>
< tr class =row_even>< td> test< / td>< td> test< / td>< / tr>
< / table> ;

谢谢,
Wesley

< col> 的类不会被< td> 继承。 code>。您需要对HTML进行调整。将 col1 改为第一个< td> 在表格中



http://jsfiddle.net/ uqJHf / 6 /



-

  ; table> 
< colgroup>
< col class =col1/>
< col />
< / colgroup>
< tbody>
< tr class =row_odd>
< td class =col1> test< / td>
< td> test< / td>
< / tr>
< tr class =row_even>
< td class =col1> test< / td>
< td> test< / td>
< / tr>
< / tbody>
< / table>


See this fiddle:

http://jsfiddle.net/uqJHf/

I have set the first column to show up with a red background.

However, the odd/even styling is overriding it. Even with added !important;

Is there any way I can get this fixed? (without having to add classes to the

tr.row_odd td {
    background:#efefef;
}
tr.row_even td {
    background:green;
}
.col1  { background:red !important; }

<table>
<col class="col1"></col>
<tr class="row_odd"><td>test</td><td>test</td></tr>
<tr class="row_even"><td>test</td><td>test</td></tr>
</table>

Thanks, Wesley

解决方案

The Class from HTML <col> does not get inherited by <td>. You need to adh´just the HTML. Give class col1 to first <td> in table row

http://jsfiddle.net/uqJHf/6/

--

<table>
    <colgroup>
        <col class="col1" />
        <col />
    </colgroup>
    <tbody>
        <tr class="row_odd">
            <td class="col1">test</td>
            <td>test</td>
        </tr>
        <tr class="row_even">
            <td class="col1">test</td>
            <td>test</td>
        </tr>
    </tbody>
</table>

这篇关于表样式 - col类应该重写超过td类..如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆