Continuous CSS transitions

泄露秘密 提交于 2019-12-18 16:52:27

问题


Is there a way to continuously animate a background image's background-position property using CSS3 transitions?


回答1:


Yes, it's possible - DEMO

div
{
    background: url(http://lorempixel.com/100/100);
    height: 100px;
    width: 100px;

    -webkit-animation: slide 2s linear infinite;
       -moz-animation: slide 2s linear infinite;
            animation: slide 2s linear infinite;
}


@-webkit-keyframes slide
{
    0%   {background-position: 0 0;}
    100% {background-position: 100px 0;}
}​

@-moz-keyframes slide
{
    0%   {background-position: 0 0;}
    100% {background-position: 100px 0;}
}

@keyframes slide
{
    0%   {background-position: 0 0;}
    100% {background-position: 100px 0;}
}



来源:https://stackoverflow.com/questions/12224047/continuous-css-transitions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!