Random “start point” for CSS keyframes animation

前端 未结 4 1469
[愿得一人]
[愿得一人] 2021-02-14 06:52

I have a list of boxes with a background image that scrolls vertically with:

@keyframes movie {
   0% { background-position: 50% 5%; }
   50% { background-positi         


        
4条回答
  •  半阙折子戏
    2021-02-14 07:16

    You can use animation-delay.

    animation-delay: 10s;
    

    Or inside your shorthand:

    animation: movie 50s linear 10s infinite;
    

    Maybe easier to handle, with some pseudo-classes:

    .movie:nth-of-type(1) {
      animation-delay: 10s;
    }
    
    .movie:nth-of-type(2) {
      animation-delay: 20s;
    }
    
    .movie:nth-of-type(3) {
      animation-delay: 30s;
    }
    

提交回复
热议问题