我有两个动画使用 JS 来激活一些 CSS 动画。似乎在 Chrome 和 Safari 中运行良好,但在 Moz 中运行良好。我还没有在 IE 中测试过(因为我在我的 MBP 上)但肯定那也很糟糕。不知道为什么。
JS:
<script type="text/javascript">
$(document).ready(function() {
$('.background-image').on('webkitAnimationEnd', function(e) {
$(this).addClass('visible');
});
});
$(document).ready(function() {
$('#countries').on('webkitAnimationEnd', function(e) {
$(this).addClass('visible');
});
});
</script>
CSS:
`@-webkit-keyframes fade-in {
0% { opacity: 0; }
100% { opacity: 1; }
}
.background-image {
background: url('images/bg.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: 3s;
}
.background-image.visible {
opacity: 1;
}
#countries{
width: 800px;
height: 300px;
position: absolute;
background: rgb(0, 0, 0); /* Fall-back for browsers that don't support rgba */
background: rgba(0, 0, 0, .9);
left: 100px;
top: 80px;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
opacity: 0;
-webkit-animation-name: fade-in;
-webkit-animation-duration: .8s;
-webkit-animation-timing-function: ease-in;
-webkit-animation-iteration-count: .8;
-webkit-animation-delay: 4.5s;
}
#countries.visible {
opacity: 1;
}