CSS 删除元素的继承属性(框大小)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12863835/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Removing inherited property of an element (box-sizing)
提问by Gokul Kav
I am using a jQuery light box plugin on a bootstrap site. It has box-sizing: border-box
set via universal selector.
我在引导站点上使用 jQuery 灯箱插件。它已box-sizing: border-box
通过通用选择器进行设置。
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
The light box div does not appear right because of this (sometimes a vertical scrollbar appears). Once we remove this through web inspector it appears ok. Is there any way to remove the box-sizing property of this particular element.
box-sizing:''
or box-sizing:none
does not appear to work.
因此灯箱 div 显示不正确(有时会出现垂直滚动条)。一旦我们通过网络检查器删除它,它看起来就可以了。有什么方法可以删除此特定元素的 box-sizing 属性。
box-sizing:''
或box-sizing:none
似乎不起作用。
回答by VKen
回答by user5371360
you can use
您可以使用
*:not(.classname){
box-sizing : border-box;
}
classname
will be the class of element you want to exclude from the universal selector.
classname
将是您要从通用选择器中排除的元素类。
回答by Karthik P
I had a similar problem with bootstrap and I did override the box-sizing CSS property for <a>
like this,
我在 bootstrap 中遇到了类似的问题,我确实<a>
像这样覆盖了 box-sizing CSS 属性,
a *,
a *:before,
a *:after {
-webkit-box-sizing: content-box !important;
-moz-box-sizing: content-box !important;
box-sizing: content-box !important;
}
Customize it for your need.
根据您的需要定制它。
回答by mfralou
Override like this:
像这样覆盖:
* {
box-sizing: border-box!important;
}