我有这个:

 <style type="text/css">
.blackitout {
    position:fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
    background: #000 url('/images/loading.gif') no-repeat center;
    opacity: 0.7;
    z-index:99;
}
</style>
<script>
function testfunction (){
    $('#mytest').addClass('blackitout');
}
</script>


我有一个onclick调用我的测试功能的链接。这将上述类添加到一个空的div中。这使我的页面变暗,并且正在加载gif。在Firefox中工作。但不是铬。在chrome中,如果我手动将图像加载到空白页面上,然后在css中的链接周围添加或删除引号并保存。它将开始工作一段时间。也许我只需要一个比空div类和添加类更好的方法(添加该类(在下一页加载时将其删除))。

最佳答案

尝试这个

.blackitout {
    position:fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
    background-color: #000;
    background-image: url('/images/loading.gif') ;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.7;
    z-index:99;
}

关于jquery - 未在Chrome中加载背景图片,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23618635/

10-09 15:39
查看更多