S
S
Sergei Gurdjiyan2016-12-18 23:55:02
Sass
Sergei Gurdjiyan, 2016-12-18 23:55:02

How to use variables in SASS?

There is such a code

.image
    position: relative
    @for $i from 0 to 7
      &:nth-child(#{$i + 1})
        &:before
          content: ''
          @include sprite($advantages-$i)

I want to use a cycle, in it @include sprite($advantages-1)- will return the styles for the image from the sprite.
How to use variables correctly so that at each iteration of the loop I would get @include sprite($advantages-1), @include sprite($advantages-2)etc.?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2016-12-19
@bingo347

You have a cycle from 0, so you need to @include sprite($advantages - $i + 1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question