我如何重写特定图像的img css。覆盖默认img css
让说,
我在我的网站的CSS像
img{
border:2px solid #ECECEC;
padding:4px;
}
我有一个IMG在该网站说<img id="example" src="../example.png"/>
现在,我不想申请IMG CSS到这个特定的图像。
我怎样才能做到这一点?
感谢
我如何重写特定图像的img css。覆盖默认img css
让说,
我在我的网站的CSS像
img{
border:2px solid #ECECEC;
padding:4px;
}
我有一个IMG在该网站说<img id="example" src="../example.png"/>
现在,我不想申请IMG CSS到这个特定的图像。
我怎样才能做到这一点?
感谢
img#example {border:none !important; }
无以实例ID
边框图像使用id
作为一个选择,改变你想要的CSS属性。
#example{
border:0;
padding: 0;
}
如果由于某些原因您无法触摸标记,则可以使用属性选择器。
img[src="../example.png"] {
border:0;
padding:0;
}
添加一个单独的类图像 例
<img class="example" id="example" src="../example.png"/>
.example{
border:0 !important;
padding: 0 !important;
}
没有必要使用`!important`作为id选择具有比标签选择较高的特异性。 – 2010-12-22 15:17:33
尼斯加比。 +1感谢您的信息。 http://jsfiddle.net/huhu/4UPSS/ – haha 2010-12-22 15:25:41