0

我通过 jquery 将背景图像加载到 DiV 中,偶尔会弹出一个模式,它会拉伸屏幕高度,以便您必须滚动。

我想让我的 bg 图像随视图滚动,但问题是这height:100%显然意味着原始高度的 100%。div 不会随着屏幕的其余部分拉伸。

这是为什么?这是我的代码:

#bgDiv {
    display: none;
    height: 100%;
    width: 100%;
    background-repeat: no-repeat;
    background-position: center center;
        background-attachment:fixed;
    top:0;
    right:0;
    position: absolute;
    z-index: -9999;
}

谢谢!

4

1 回答 1

1

如果您将位置设置为固定而不是绝对位置,它应该保持不变,即使在滚动时也是如此。

于 2013-01-21T21:58:38.063 回答