javascript - css() 没有为 body 标签设置背景属性

标签 javascript java jquery html css

我在我的代码中使用了这些东西,但没有一个起作用。请建议我任何其他方法来解决这个问题。

// #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/

相关文章:

jquery - 将 OO 添加到 jQuery.dialog()

java - 在数据库中插入/更新行时更新列表

java - 使用 HashMap 和数组组织锻炼信息

javascript - 删除空格后的所有字符串

Java 正则表达式使用模式替换文本之间

java从像素矩阵创建BMP图像并反转

c# - 将 C# 字符串数组转换为 Javascript 数组

javascript - 我可以根据点击指定的按钮显示一个 div,隐藏所有其他 div 吗?

javascript - 我应该每次打开一个 IDBDatabase 还是保持一个实例打开?

javascript - 如何将 json 从 JavaScript 传递到 iPad native 应用程序?