Extract piece of SASS code

1

Hello, I'm creating a branch break using SASS but it has a piece of code that repeats a few times and I do not know how to extract it.

@while $newColumn <= $columnNumber {
    .col-#{$newColumn}{
        $calcWidth: (100% / $columnNumber) * $newColumn;
        -ms-flex-preferred-size: $calcWidth;
        flex-basis: $calcWidth;
        max-width: $calcWidth;
    }
    $newColumn: $newColumn + 1;
}

I wanted to create a new @mixin that does this calculation, to be able to replace this many lines:

$calcWidth: (100% / $columnNumber) * $newColumn;
-ms-flex-preferred-size: $calcWidth;
flex-basis: $calcWidth;
max-width: $calcWidth;

I'm a beginner programmer so I do not know if I was very clear. Thanks!

    
asked by anonymous 03.12.2017 / 11:29

0 answers