用JQuery覆盖正文背景? [英] Overriding body background with JQuery?

查看:83
本文介绍了用JQuery覆盖正文背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$('body')。css('background-color','blue'); 对我不起作用。

页面上似乎还有其他匹配的CSS规则。

There seems to be other matched CSS rules that prevail on the page.

有没有办法强制此CSS工作?当我尝试使用背景图像时,这也行不通...

Is there a way I can force this CSS to work? This also doesn't work when I try background-image...

使用Google Chrome浏览器的CSS资源管理器,可以为主体设置三种不同的匹配CSS规则。

With Google Chrome's CSS explorer there are three different matched CSS rules for body.

我不知道它是如何工作的,以及为什么上面的JQuery无法正常工作。

I don't understand how this works and why this above JQuery isn't working.

请向我提供知识!

答案非常适合覆盖CSS!谢谢

The answer is perfect for overriding CSS! Thanks

注意:从一开始就清除缓存并浏览数据,这很有帮助;)

Note: Clear cache and browsing data from the beginning of time, it helps ;)

推荐答案

如果要在冲突时强制应用此样式,请在样式之后使用!important

If you want to force this style to be applied in case there are conflicts then use !important after the style.

$(function(){
    $('body').css('background-color', 'blue !important');
});

这篇关于用JQuery覆盖正文背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆