我有以下情况。
在我们的网站标题中,One CSS属性background-image:url(image.png);
被background-color:red!important.
覆盖。我无法更改HTML或类,因为它们是由jQuery动态生成的。
即使属性值background-color:red!important
应保持不变,将!important
添加到背景图片也会影响其他页面。
但只有一页,我希望背景图片显示覆盖背景颜色。我怎么能这样做?
希望我有道理。
更新
以下是CSS选择器和正确的DOM结构(标题中所有页面上的)
#my_id.section{
background-color:red!important;
}
#my_id.section{
background-image:url(image.png); /*.. it's overridden with bg-color..*/
}
在我想要的唯一一页上
#my_id.section{
background-color:red!important;
}
#my_id.section{
background-image:url(image.png)!important; /*.. this should not be overridden with bg-color even though it has !important..*/
}
请注意:由于CSS是动态生成的,用户可以更改其值,因此无法对其进行调整。
答案 0 :(得分:0)
也许你可以尝试这样的事情:
$(function(){
$("#my_id.section").css("background-image", "url(image.png)", "important");
});
如果适用于您的情况......