我遇到了jQuery(document).ready(function(){问题 - 我的问题是当我清除缓存时,它没有等待背景图像先加载然后淡入。所以发生的情况是在包装器淡入之前有一个延迟,然后图像在加载时明显缩小屏幕。
我正在 Wordpress 上使用 Headway 主题进行构建。
这让我发疯:)
CSS:
@-webkit-keyframes fade-in {
0% { opacity: 0; }
100% { opacity: 1; }
}
.background-image {
background: url('http://www.aliceandowl.com/wp-content/uploads/2015/03/Purity-London-Homepage-Banner.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0;
-webkit-animation-name: fade-in;
-webkit-animation-duration: 1s;
-webkit-animation-timing-function: ease-in;
-webkit-animation-iteration-count: 1;
-webkit-animation-delay: 2s;
-webkit-animation-fill-mode: forwards;
}
.background-image.visible {
opacity: 1;
}
Run Code Online (Sandbox Code Playgroud)
jQuery:
jQuery(document).load(function() {
jQuery('.background-image').on('webkitAnimationEnd', function(e) {
jQuery(this).addClass('visible');
}); …Run Code Online (Sandbox Code Playgroud)