动画背景没有固定
Animated background not staying fixed
嘿,伙计们,我正在为我的网站开发一个新的背景。我试着把它动画化一点。我目前在这里工作:http://wow-x.com/back/
正如您所看到的,当您向下滚动页面时,名为"background"的div不会保持"固定"。。。我似乎无法使它保持固定。
我的CSS如下:
body {
background-color: #0a0a0a;
color: #a2a2a2;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 1.4;
margin: 0;
padding: 0;
background-image: url(http://wow-x.com/board/images/blackevo4-pure/background.jpg);
background-repeat: no-repeat;
background-position: center top;
background-attachment:fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#background {
background: url(http://wow-x.com/board/images/blackevo4-pure/back1.jpg);
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
opacity:0.1;
z-index:-1;
}
#midground {
background: url(http://wow-x.com/board/images/blackevo4-pure/midground.png) repeat 20% 20%;
background-attachment:fixed;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index:-2;
height:100%;
width:100%;
}
#foreground {
background: url(http://wow-x.com/board/images/blackevo4-pure/foreground.png) repeat 90% 110%;
background-attachment:fixed;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index:-3;
height:100%;
width:100%;
}
如果您试图保持#background
div固定,请将其位置从position: absolute;
更改为position: fixed;
将position
属性设置为绝对值意味着元素将相对于其第一个定位的祖先进行定位。在您的情况下,这是主体本身,因此图像会随页面一起滚动。
将position
属性设置为固定意味着元素将相对于窗口定位。所以它的位置将独立于滚动位置。
简单的修复使用。。
position:fixed
到您的#background
相关文章:
- 如何使用css动画/javascript使具有背景图像的元素出现
- CSS动画背景图像的过渡越来越暗
- 如何用jquery动画改变背景颜色,就像一个过渡
- 如何动画删除悬停后的背景
- 仅为背景位置X轴制作动画
- 如何像下面给出的页面一样获得背景动画
- AngularJs设置背景颜色/颜色的动画
- 动画渐变(javascript)背景不会延伸到窗口的整个高度
- jQuery动画背景大小属性
- 视差'背景图像/位置/附件'jQuery的动画很不稳定
- SVG模式动画和背景淡入问题
- 使用CSS或SVG设置与背景颜色匹配的文本颜色的动画
- CSS3 或 HTML5 - 如何制作背景动画,如 HTML5 页面中漂浮的云
- 延迟并设置背景动画
- Jquery UI使用scroll_pos制作背景动画
- 设置画布背景动画
- 烟雾不透明度背景动画
- 如何同时创建ajax请求和背景动画
- 如何使背景动画进入循环(重复函数)
- 在用户激活动画期间暂停所有背景动画(jquery)