我见过很多不同的方法来做到这一点,长话短说,这就是我正在使用的方法。这似乎对其他人有效,但对我无效。有什么不同的写法的想法吗?
当前的 CSS
.aw-widget-current-inner div.aw-widget-content a.aw-current-weather p span.aw-temperature-today b {
margin: 0px !important;
}
我想要的是
.aw-widget-current-inner div.aw-widget-content a.aw-current-weather p span.aw-temperature-today b {
margin: 20px;
}
这是 JS
<script>
$(init);
function init() {
$('.aw-widget-current-inner b').css({
'margin':'20px 0px -10px 0px'
});
}
</script>
最佳答案
!important
覆盖使用 .css()
函数创建的内联样式。删除 CSS 中的 !important
,使用 jQuery 进行样式设置应该可以。
关于javascript - 用 javascript 更改 css 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24069512/