javascript - 页面调整大小时背景封面

标签 javascript jquery html css

我的页面有一些有时会改变页面高度(故意)的动画,所以最初当页面加载并且页面高度为 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/

相关文章:

php - 对查询字符串条件进行排序的正确方法

jQuery-ui 未加载或选项卡不拉下其他内容?

php - 使用javascript转换日期格式

php - 如何使用 PHP 显示 Bootstrap 模式?

javascript - 如何防止ajax post请求提交两次?

javascript - 两个jquery工具互相干扰

javascript - 如何淡化我的背景而不是文本?

html - 多行文本填充

javascript - javascript only polymer 组件有什么意义

javascript - Safari 顶部、左侧过渡问题