Continuous CSS transitions

前端 未结 1 806
無奈伤痛
無奈伤痛 2021-01-03 01:15

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

相关标签:
1条回答
  • 2021-01-03 01:44

    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;}
    }
    

    0 讨论(0)
提交回复
热议问题