我有一个通用规则,给所有div一个背景图像。 我有一个div (id='a'),我不希望它有背景图像。 我需要给出什么css规则呢?
当前回答
因为在css3中可以设置多个背景图像,设置“none”只会创建一个新层并且不隐藏任何东西。
http://www.css3.info/preview/multiple-backgrounds/ http://www.w3.org/TR/css3-background/#backgrounds
我还没有找到解决办法。
其他回答
div#a {
background-image: none;
}
当background-image: none !没有效果。 你可以使用:
background-size: 0 !important;
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:not(#a) { // add your bg image here //}
Try:
div#a {
background-image:none
}
推荐文章
- 使伸缩项目正确浮动
- 如何取消最大高度?
- 形式内联内的形式水平在twitter bootstrap?
- 自定义元素在HTML5中有效吗?
- 如何选择在最后一个子元素之前的元素?
- 如何触发自动填充在谷歌Chrome?
- CSS变换,锯齿边缘在铬
- 创建圈div比使用图像更容易的方法?
- 强迫孩子服从父母的弯曲边界在CSS
- 为什么Chrome浏览器不正确地确定页面是在不同的语言,并提供翻译?
- 在CSS中@apply是什么?
- 在网页上用鼠标模拟震颤(例如帕金森病)?
- Bootstrap抛出Uncaught错误:Bootstrap的JavaScript需要jQuery
- 如何改变文本区域的边框颜色:焦点
- 我如何设置背景颜色为文本的宽度,而不是整个元素的宽度,使用CSS?