Reputation: 5
i have a list of box.
#box-1 {}
#box-2 {}
#box-3 {}
in sass i wrote:
@mixin boxnumerati($levels)
{
@for $i from 1 to $levels
{
#box-#{$i}
{
@if $i == 2 {
background: #ff0000;
height: 200px;
width:200px;
display: inline-block;
} @else {
background: #000;
height: 100px;
width:100px;
display: inline-block;
}
}
}
}
I want that every multiple of 2 the box is red. how can i do that?
Upvotes: 0
Views: 44
Reputation:
You can use modulo operator %:
@mixin boxnumerati($levels)
{
@for $i from 1 to $levels
{
#box-#{$i}
{
@if $i%2 == 0 {
background: #ff0000;
height: 200px;
width:200px;
display: inline-block;
} @else {
background: #000;
height: 100px;
width:100px;
display: inline-block;
}
}
}
}
Upvotes: 1