【发布时间】:2016-04-02 18:43:01
【问题描述】:
我正在尝试在页面加载后加载背景,但它似乎不像我预期的那样工作。
我之前在 css 中的代码是:
html {
background: url(<?php echo $this->Cdn->getUrl(); ?>/images/photos/bg-blurred.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-color: #0c1d31;
}
现在我用 jQuery 试试:
jQuery(document).ready(function () {
jQuery('html').css({
'background-image': "url('<?php echo $this->Cdn->getUrl(); ?>/images/photos/bg-blurred.jpg')",
'background-size': "cover",
'background-color': "#0c1d31",
'-webkit-background-size': "cover",
'-moz-background-size': "cover",
'-o-background-size': "cover",
});
});
似乎 '-webkit-background-size' 和 '-moz-background-size' 和 '-o-background-size' 在使用 jQuery.css 时不起作用。其他 css 属性工作正常。
有什么想法吗?
【问题讨论】:
-
请在代码中添加一个起点,以便正确快速地回答您的问题。另见stackoverflow.com/help/mcve
-
@Roy 我不明白我的问题有什么问题?
-
浏览器在很长一段时间内都不需要前缀,为什么还要麻烦?
标签: javascript jquery html css