CSS:没有属性(CSS :Not attribute)

2019-08-06 23:06发布

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

只使用CSS,我需要设置不具有表的宽度, width=100% 事情是这样的:

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

Answer 1:

属性选择被包围[]所以你的选择应该是这样的,而不是:

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


Answer 2:

使用该表的类,并提出,在不

table:not(.foo) {

}

需要在不和宽度= 100%的选择器没有一个



Answer 3:

如何使用内嵌样式你想有不同的宽度表?

<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%; }


Answer 4:

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



文章来源: CSS :Not attribute