第一个表格栏的CSS样式(该栏的第一个单元格除外) [英] CSS style for first table column except first cell of that column

查看:212
本文介绍了第一个表格栏的CSS样式(该栏的第一个单元格除外)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是<table>:

<table class='census'>
    <tr>
        <th colspan="2">My Title</th>
    </tr>
    <tr>
        <td colspan="2" class='chart'><SOME PIE CHART, GENERATED WITH JS></td>
    </tr>
    <tr>
        <td>Some title</td>
        <td>Some Data</td>
    </tr>
    <tr>
        <td>Some title</td>
        <td>Some Data</td>
    </tr>
    <tr>
        <td>Some title</td>
        <td>Some Data</td>
    </tr>
    <tr>
        <td>Some title</td>
        <td>Some Data</td>
    </tr>
    <tr>
        <td>Some title</td>
        <td>Some Data</td>
    </tr>
</table>

我需要为第一列设置固定宽度.可以很容易做到:

I need to set fixed width for the first column. It could easily be done:

.census td:first-child {
    background-color: #F0F8FE;
    width: 250px;
}

现在有问题! 使用JS PIE CHART固定宽度的螺钉.

Now the problem! Fixed width screws with JS PIE CHART.

因此,我需要对所有第一个<td>标签应用固定宽度,但带有colspan="2"的标签将包含我的图表.

So i need to apply fixed width to all first <td> tags except one with colspan="2" that will contain my chart.

(到目前为止)我唯一想出的东西:

The only thing i could come up with (so far) if this:

.census td:first-child:not(.chart) {
    background-color: #F0F8FE;
    width: 250px;
}

它给我带来了所有浏览器意外的结果. 此时我迷路了.

It brings me unexpected results in all browsers. I'm lost at this point.

推荐答案

您是否可以仅将其放在图表类之后呢?

Can you not just override it be putting the chart class after it e.g.

   .census td:first-child {
        background-color: #F0F8FE;
        width: 250px;
    }

    .census td.chart {
      width: auto;
      etc...
    }

这篇关于第一个表格栏的CSS样式(该栏的第一个单元格除外)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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