我在我的代码中使用了这些东西,但没有一个起作用。请建议我任何其他方法来解决这个问题。
// #1
if ("${actionBean.backgroundImage}" != null){
$(document.body).css("pointer-events", "none");
$(document.body).css("cursor", "default");
$(document.body).css("background", "url('${actionBean.backgroundImage}') no-repeat fixed center -80px / cover !important");
}
// #2
if ("${actionBean.backgroundImage}" != null){
$('html, body').css("pointer-events", "none");
$('html, body').css("cursor", "default");
$('html, body').css("background", "url('${actionBean.backgroundImage}') no-repeat fixed center -80px / cover !important");
}
// #3
if ("${actionBean.backgroundImage}" != null){
$("body").css("pointer-events","none");
$("body").css("cursor","default");
$("body").css("background", "url('${actionBean.backgroundImage}') no-repeat fixed center -80px / cover !important");
}
// #4
if ("${actionBean.backgroundImage}" != null){
$(body).css("pointer-events", "none");
$(body).css("cursor", "default");
$(body).css("background", "url('${actionBean.backgroundImage}') no-repeat fixed center -80px / cover !important");
}
最佳答案
尝试使用背景的单独属性,例如:
$(body).css("background", "no-repeat fixed center -80px / cover !important");
$(body).css("background-image", "url('${actionBean.backgroundImage}')");
并且这必须包含在正文下方。
关于javascript - css() 没有为 body 标签设置背景属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35647830/