修改important样式

2017-11-22  本文已影响0人  littleStar_up

有important的样式修改起来有点头疼,样式比js里的优先级还高,修改样式加important发现无效,样式并没有修改

.a {
    top: 0;
    right: 0;
    position: fixed;
    z-index: 3001 !important;
    overflow: auto;
    margin: 0
}
<div class="a">index</div>

然后发现div的层级太高了,想改掉

document.getElementsByClassName("a")[0].style.zIndex = 100!important;//没有效果
$(".a").css("z-index", "100!important;");//还是没有效果
$(".a").css("cssText", "z-index:100!important;");//这个就可以了
$(".a").css("cssText", "width:650px !important;overflow:hidden !important");//多个
上一篇 下一篇

猜你喜欢

热点阅读