1

I am having an issue with a Sass loop. I want to make the animation .1 seconds, .2 seconds etc...Here is the loop:

@for $i from 1 through 6 {
  #elem span:nth-child(#{$i}) {
    animation-delay: .#{$i}s;
  }
}

The issue seems to be with the period here: .#{$i}s

If I remove it it works fine, but I get my animation in seconds and not fractions of a second as I would like it.

Hashem Qolami
  • 97,268
  • 26
  • 150
  • 164
Grinfax
  • 33
  • 3

1 Answers1

1

You could wrap the .#{$i}s by quotes and then use unquote() string function to fix the issue, as follows:

@for $i from 1 through 6 {
  #elem span:nth-child(#{$i}) {
    animation-delay: unquote(".#{$i}s");
  }
}

From the doc:

unquote($string) Removes quotes from a string. If the string is already unquoted, this will return it unmodified.

Hashem Qolami
  • 97,268
  • 26
  • 150
  • 164
  • @Grinfax You are welcome. Seems you are new to Stackoverflow, If so, please consider *[What should I do when someone answers my question?](http://stackoverflow.com/help/someone-answers)*. – Hashem Qolami Mar 14 '14 at 16:50