我正在寻找以下解决方案。在我的CSS中,我有以下内容:
img, a img {
max-width: 100%;
vertical-align: middle;
}这段代码对于我的WordPress主题和响应性的网页设计是必要的。现在,我想将max-width属性重写为auto。当我这么做的时候,它不会覆盖:
#pixel-perfect img {
max-width: auto !important;
position: absolute;
margin: -200px 0 0 -140px;
z-index: -9999;
}我做错什么了?
发布于 2013-11-10 19:29:41
您只是想取消设置max-width属性吗?如果是,试着:
#pixel-perfect img {
max-width: none;
}发布于 2013-11-10 19:30:13
我认为这是因为a img比#pixel-perfect img更具体。元素选择器比id选择器更具体(因此在本例中有两个元素vs 1个元素和1个id)。
为了修复它,您必须向声明中添加一个元素,例如:
a#pixel-perfect img {
max-width: auto !important;
}发布于 2013-11-10 19:36:55
确保您的#pixel-perfect img CSS声明在img, a img声明下面,否则它将被覆盖。
#pixel-perfect img {
max-width: none;
width: auto;
position: absolute;
margin: -200px 0 0 -140px;
z-index: -9999;
}https://stackoverflow.com/questions/19894059
复制相似问题