我想仅在加载此元素时(使用背景)为元素设置动画。我试过这个但是不起作用:
CSS:
#topimg{
background: rgba(0, 0, 0, 0) url(../img/bg.jpg) 0 0 no-repeat fixed;
background-size: cover;
}
HTML:
<div id="topimg"> </div>
JAVASCRIPT:
$('#topimg').load(function() {
$('#topimg').css({opacity: 0}).animate({opacity: 1}, {duration: 1500});
});