我正在使用 jQuery 淡入我的主页,但它目前是从白色淡入。有没有办法从黑页淡入?这与加载 iframe 时的情况相同,它会闪烁白色。我知道这可以修复,所以我认为可能也有修复方法。
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>
最佳答案
是的,尝试更改 <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);
})
尚未测试,但可以为您工作:)
关于javascript - 带有背景图像的 jQuery 淡入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16245776/