TIM*_*MEX 1 html javascript css templates css3
<div class="abc">
</div>
.abc{
background: url("blah.jpg") no-repeat;
width:200px;
height:200px;
}
Run Code Online (Sandbox Code Playgroud)
我的背景图像是200 x 600.如何在div上下移动它(我希望div保持200x200,但是较长的图像会上下移动.)
我不想使用Javascript来执行此操作.(因为这样做不会使用硬件而且会很慢.)
@keyframes bounce-background {
from {
background-position: top;
}
50% {
background-position: bottom;
}
to {
background-position: top;
}
}
.abc {
animation-name: bounce-background;
animation-timing-function: ease-in-out;
animation-duration: 2s;
animation-iteration-count: infinite;
/* For Chrome & Safari */
-webkit-animation-name: bounce-background;
-webkit-animation-timing-function:ease-in-out;
-webkit-animation-duration:2s;
-webkit-animation-iteration-count:infinite;
}
Run Code Online (Sandbox Code Playgroud)
您应该在您支持的浏览器的供应商前缀下重复这些未最终确定的CSS3属性(例如,@-moz-keyframes @-o-keyframes @-webkit-keyframes等等).