2013-04-26 121 views
1

我正在使用jQuery淡入我的主页,但它目前从白色渐变。有没有办法从黑屏中淡入?当加载一个iframe并且它闪烁白色时,这是同样的事情。我知道这是可以修复的,所以我认为这也可能是一个解决方案。jQuery淡入背景图片

CSS:

html { 
    background: black url(images/bg.jpg) no-repeat 200px center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
    height: 100%; 
    display: none; 
} 
body { 
    margin: 0; 
    height: 100%; 
    padding-left: 40px; 
    padding-top: 25px; 
} 

脚本:

<!doctype html> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title></title> 
<link href="home.css" rel="stylesheet" type="text/css"> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script> 
<script type="text/javascript"> 
    $(document).ready(function(){ 
     $('html').fadeIn(3000); 
    }) 
</script> 
</head> 
<body> 
</body> 
</html> 

回答

3

是的,请尝试更改<body>

<body><div id="page">Content here</div></body> 

CSS来

html,body{background:#000; height: 100%} 
#page{ 
    background: black url(images/bg.jpg) no-repeat 200px center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
    height: 100%; 
    display: none; 
} 

和JavaScript来

$(document).ready(function(){ 
    $('#page').fadeIn(3000); 
}) 

没有带测试,但可能会为你工作:)

+0

这只是做同样的事情,完全与白色闪光。 – pianoman 2013-04-26 21:59:16

+0

再试一次,我更新了一些CSS – Ejaz 2013-04-26 22:00:41