Create a loop using SCSS to change background images with CSS3 animate?

前端 未结 1 357
走了就别回头了
走了就别回头了 2021-01-17 01:41

I have created the beginning of a CSS3 animation as shown below. I have tried to use @for and @each within SCSS to create a loop which will increment the %\'s and also the n

相关标签:
1条回答
  • 2021-01-17 02:43

    Sass can only increment (or decrement) @for loops by 1. If you want a different interval, you need to use math to get there:

    @-webkit-keyframes perimeter {
      @for $i from 0 through 39 {
        #{$i * 2.564102564102564%} {
          background-image: url('../img/perimeters/PerimeterFountains#{$i}.png');
        }
      }
    }
    

    Related: Rounding numbers in Sass and adjusting the amount of decimals

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