我的页面有一些有时会改变页面高度(故意)的动画,所以最初当页面加载并且页面高度为 100% 时,背景图像会覆盖页面。 但是当它运行动画时,页面高度可以超过 100%。有效覆盖所有背景的唯一方法是将背景高度从自动更改为更大的值(例如 200%),但这样做我也会更改页面高度。换句话说,是否可以在动画运行时(动态地)覆盖页面,而在动画不运行时将页面高度保持在 100%?
我的背景CSS代码:
background: url(background2.jpg)repeat 5% 5%;
position: absolute;
background-size:cover;
top: 0; left: 0; right: 0; bottom: 0;
z-index: 400;
height: auto;
width: auto;
最佳答案
$(document).ready(function(){
var isAnimating = $("#someid").is(':animated');
//will return true if selected element animating
if(isAnimating == true){
$('#div').css('height','value');
}
else{
$('#div').css('height','value');
}
});
关于javascript - 页面调整大小时背景封面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23407110/