简体   繁体   English

如何为除一个类之外的所有元素创建css规则?

[英]How to create a css rule for all elements except one class?

I have created a CSS stylesheet for my project. 我为我的项目创建了一个CSS样式表。 Is there any way I can create a css rule that applies to all table elements EXCEPT table elements belonging to the class "dojoxGrid"? 有什么办法可以创建一个适用于所有表元素的css规则除了属于“dojoxGrid”类的表元素外? Something like: 就像是:

.not(dojoxGrid) table{
    width:100%;
    border-top:1px solid #dddddd;
    border-left:1px solid #dddddd;
    border-right:1px solid #dddddd;
    margin:1em auto;
    border-collapse:collapse;
}

The negation pseudo-class seems to be what you are looking for. 否定伪类似乎是你正在寻找的。

table:not(.dojoxGrid) {color:red;}

It's not supported by ≤ IE8 though . 但IE8不支持它

Wouldn't setting a css rule for all tables, and then a subsequent one for tables where class="dojoxGrid" work? 不会为所有表设置一个css规则,然后为class =“dojoxGrid”工作的表后续设置一个css规则吗? Or am I missing something? 或者我错过了什么?

The safest bet is to create a class on those tables and use that. 最安全的选择是在这些表上创建一个类并使用它。 Currently getting something like this to work in all major browsers is unlikely. 目前,在所有主流浏览器中使用此类功能的可能性不大。

我只是遇到了同样的问题,但是:在我的情况下并没有正常工作所以我更新了关于身体负荷的css规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM