开发者

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

开发者 https://www.devze.com 2022-12-23 22:05 出处:网络
I have created a CSS stylesheet for my project. Is there any way I can create a css rule that applies to all table elements EXCEPT table elements belonging to the class \"dojoxGrid\"? Something like:

I have created a CSS stylesheet for my project. Is there any way I can create a css rule that applies to all table elements EXCEPT table elements belonging to the class "dojoxGrid"? Something like:

.not(dojoxGrid) table{
    width:100%;
    border-top:1px solid #dddddd;
    border-left开发者_如何学C: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.


Wouldn't setting a css rule for all tables, and then a subsequent one for tables where class="dojoxGrid" work? 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号