49

我有几个 HTML 表格。这些表没有 CSS 类。这两个表都有width="100%"属性。其他表没有该width属性。

仅使用 CSS 我需要设置没有width=100%. 像这样的东西:

table:not(width="100%"){
    width: myValue;
}
4

4 回答 4

104

属性选择器由 包围[],因此您的选择器应如下所示:

table:not([width="100%"]) {
    width: myValue;
}
于 2013-01-15T14:30:23.800 回答
1

在该表上使用一个类并将其放在 not

table:not(.foo) {

}

你需要一个在 not 和 width = 100% is not one 中的选择器

于 2013-01-15T14:30:40.460 回答
-1

如何为您想要不同宽度的表格使用内联样式?

<table style="width:95%">
    <tr>
        <td></td>
    </tr>
</table>

或者一个单独的类:

<table class="customWidth">
    <tr>
        <td></td>
    </tr>
</table>

CSS:

table { width:100%; }
table.customWidth { width:95%; }
于 2013-01-15T14:31:16.047 回答
-3

只写在css文件夹中table { width: 100% };

于 2013-01-15T14:30:45.650 回答