我有一个通用规则,给所有div一个背景图像。 我有一个div (id='a'),我不希望它有背景图像。 我需要给出什么css规则呢?
当前回答
div#a {
background-image: url('../images/spacer.png');
background-image: none !important;
}
我使用了一个透明的间隔图像,除了规则来删除背景图像,因为IE6似乎忽略了background-image: none,即使它被标记为!important。
其他回答
如果你的div规则只是div{…},然后#a{…}就足够了。如果它更复杂,你需要一个“更特定”的选择器,就像CSS规范中定义的那样。(#a比div更具体,只是算法中的一个方面。)
div#a {
background-image: none;
}
因为在css3中可以设置多个背景图像,设置“none”只会创建一个新层并且不隐藏任何东西。
http://www.css3.info/preview/multiple-backgrounds/ http://www.w3.org/TR/css3-background/#backgrounds
我还没有找到解决办法。
HTML:
<div id="a" class="mydiv"></div>
CSS:
div#a {
background-image:none;
}
另一种方法:
div:not(#a) {
//all rules goes here
//add image here
//div with id a not effected by these rules
}
多重(非伪)
div:not(#a):not(#b):not(#c) {
//all rules goes here
//add image here
//div with ids not effected with these rules
}
div#a {
background-image: url('../images/spacer.png');
background-image: none !important;
}
我使用了一个透明的间隔图像,除了规则来删除背景图像,因为IE6似乎忽略了background-image: none,即使它被标记为!important。
推荐文章
- 设备像素比到底是什么?
- 我如何做一个半透明的背景?
- 强制打开“另存为…”弹出打开文本链接点击PDF在HTML
- 如何修改标签文本?
- 在CSS网格布局中等高行
- $(window).width()与媒体查询不一样
- 在HTML中还有其他有用的空格码吗,比如半空格的 , em-spaces, en-spaces等等?
- 输入触发器按钮单击
- 如何以及在哪里使用::ng-deep?
- Angular 2模板中的标签是什么意思?
- 如何设置身体高度溢出滚动
- 在输入type="number"时禁用webkit的旋转按钮?
- 如何在另一个元素之后添加一个元素?
- 我如何有效地解析HTML与Java?
- “ ”和“”有什么区别?