【发布时间】:2014-01-31 23:25:50
【问题描述】:
我正在尝试为 div 的背景位置设置动画,速度缓慢,但没有抖动的运动。你可以在这里看到我目前努力的结果:
@-webkit-keyframes MOVE-BG {
from {
background-position: 0% 0%
}
to {
background-position: 187% 0%
}
}
#content {
width: 100%;
height: 300px;
background: url(http://www.gstatic.com/webp/gallery/1.jpg) 0% 0% repeat;
text-align: center;
font-size: 26px;
color: #000;
-webkit-animation-name: MOVE-BG;
-webkit-animation-duration: 100s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
}
我已经在这里工作了好几个小时,但找不到任何可以在亚像素级别缓慢流畅地制作动画的东西。我当前的示例是根据此页面上的示例代码制作的:http://css-tricks.com/parallax-background-css3/
我所追求的动画的流畅度可以在这个页面的 translate() 示例中看到:
http://css-tricks.com/tale-of-animation-performance/
如果背景位置不能做到这一点,有没有办法用多个 div 伪造重复背景并使用 translate 移动这些 div?
【问题讨论】:
-
你知道这只适用于 webkit 浏览器吗?
-
@php_nub_qq 是的,而且翻译更兼容。例如。 w3schools.com/css/css3_2dtransforms.asp
标签: css animation background-image subpixel