Auto scrolling with CSS

前端 未结 4 1302
死守一世寂寞
死守一世寂寞 2020-12-15 12:52

In my website [based on wordpress] , I have a project slider (technically image with some text) . But that slider is not auto scrolling , there is a button for sliding left

4条回答
  •  甜味超标
    2020-12-15 13:43

    Here is an example (Fiddle) of using animations. You could apply this to your .post-list:

    .post-list {
        animation: slide infinite 3s alternate;
    }
    
    @keyframes slide {
      0% {
        margin-left: 0px;
      }
      50% {
        margin-left: -100px;
      }
      100% {
        margin-left: -200px;
      }
    }
    

    To disable the animation on hover, use:

    .post-list:hover {
        animation-play-state: paused;
    }
    

    Don't forget the vendor prefixes (-webkit-... and so on) like in Allendars answer.

    But of course you'll have to play around. This should just be a hint of how it could work.

提交回复
热议问题