【发布时间】:2013-03-22 18:11:56
【问题描述】:
所以我最近发现了 CSS3 真正令人兴奋的动画功能,并将动画应用到我网站的背景中:
我的问题是动画仅适用于加载时在浏览器窗口中可见的页面部分。如果您转到上面的链接并向下滚动,您会明白我的意思,背景图像在网站的顶部是动画的,但当您向下滚动页面时不会...
有谁知道解决这个问题的方法,以便将 bg 动画应用于整个页面?
以下是我的 CSS 代码的相关部分:
body
{
background-image:url('images/patterntest2.jpg');
background-repeat:repeat;
-webkit-animation:bgscroll 20s infinite linear;
-moz-animation:bgscroll 20s infinite linear;
-ms-animation:bgscroll 20s infinite linear;
-o-animation:bgscroll 20s infinite linear;
animation:bgscroll 20s infinite linear;
}
/*////////////////////////////////////////////////
--------------------------------------------------
* Animations
--------------------------------------------------
////////////////////////////////////////////////*/
@-webkit-keyframes bgscroll {
from {background-position:0 0;}
to {background-position:0 -520px;}
}
@-moz-keyframes bgscroll {
from {background-position:0 0;}
to {background-position:0 -520px;}
}
@-ms-keyframes bgscroll {
from {background-position:0 0;}
to {background-position:0 -520px;}
}
@-o-keyframes bgscroll {
from {background-position:0 0;}
to {background-position:0 -520px;}
}
@keyframes bgscroll {
from {background-position:0 0;}
to {background-position:0 -520px;}
}
【问题讨论】:
-
这里是 Firefox 19,它在页面下方一直有效。
-
动画是新功能吗?上世纪 90 年代,当 Geocities 还存在时,我们就有这种方式。那时候很烦,现在还很烦。
标签: css animation background