S
S
Sasha2017-03-21 11:25:26
Layout
Sasha, 2017-03-21 11:25:26

What is the correct way to write @for in SASS for a property value?

Hello.
Can you please tell me how to write @for for the property value?
I wrote simpler ones, but I have not come across this one yet.
There are thoughts to implement on the mixin.
What an enumeration that does not work should look like:

box-shadow:
  @for $i from 1 through 50{
    $basis:16 * $i;
    @if #{$i} == 50{
      ($basis)px 0 0 currentColor
    }
    else{
      ($basis)px 0 0 currentColor,
    }
  }
;

What should be the result:
box-shadow:
  -16px 0 0 currentColor,
  -32px 0 0 currentColor,
  -48px 0 0 currentColor,
  -64px 0 0 currentColor,
  -80px 0 0 currentColor
  ...
;

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2017-03-21
@userAlexander

@mixin long-shadow() {
    $shadow: "16px 0 0 currentColor";
    @for $i from 2 through 50 {
        $basis: 16 * $i;
        $shadow: #{$shadow}, #{$basis}px 0 0 currentColor;
    }
    box-shadow: $shadow;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question