SASS CSS repeat variable in for loop
up vote
2
down vote
favorite
I'm writing some SASS to output several column/row combinations for a grid. It works fine in modern browsers because they all know how to use CSS' repeat()
function. But of course, I have to develop for IE11 and Edge...
I have this function that outputs all combinations between 1-12 columns and 1-24 rows (yes, it's a lot of output, but it's necessary).
.grid-container {
width:calc(100% + 10px);
margin-left:-5px;
margin-top:-5px;
position:relative;
&.s {
@for $column from 1 through 12 {
@for $row from 1 through 24 {
&#{$column}x#{$row} {
.grid {
-ms-grid-columns: 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr;
-ms-grid-rows: 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr;
grid-template-columns: repeat($column, calc((100% / #{$column})));
grid-template-rows: repeat($row, calc((100% / #{$row})));
grid-column-gap: 0px;
grid-row-gap: 0px;
}
}
}
}
}
}
Now, I'm trying to figure out how to make the -ms-grid-columns
and -ms-grid rows
dynamic. Right now, it's just built for a 12x12 grid, but I want them to have the correct number of fr
units depending on the outputted grid size.
I found out LESS has a merge
function that would work perfectly, but I don't know what that is in SASS
css sass
add a comment |
up vote
2
down vote
favorite
I'm writing some SASS to output several column/row combinations for a grid. It works fine in modern browsers because they all know how to use CSS' repeat()
function. But of course, I have to develop for IE11 and Edge...
I have this function that outputs all combinations between 1-12 columns and 1-24 rows (yes, it's a lot of output, but it's necessary).
.grid-container {
width:calc(100% + 10px);
margin-left:-5px;
margin-top:-5px;
position:relative;
&.s {
@for $column from 1 through 12 {
@for $row from 1 through 24 {
&#{$column}x#{$row} {
.grid {
-ms-grid-columns: 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr;
-ms-grid-rows: 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr;
grid-template-columns: repeat($column, calc((100% / #{$column})));
grid-template-rows: repeat($row, calc((100% / #{$row})));
grid-column-gap: 0px;
grid-row-gap: 0px;
}
}
}
}
}
}
Now, I'm trying to figure out how to make the -ms-grid-columns
and -ms-grid rows
dynamic. Right now, it's just built for a 12x12 grid, but I want them to have the correct number of fr
units depending on the outputted grid size.
I found out LESS has a merge
function that would work perfectly, but I don't know what that is in SASS
css sass
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm writing some SASS to output several column/row combinations for a grid. It works fine in modern browsers because they all know how to use CSS' repeat()
function. But of course, I have to develop for IE11 and Edge...
I have this function that outputs all combinations between 1-12 columns and 1-24 rows (yes, it's a lot of output, but it's necessary).
.grid-container {
width:calc(100% + 10px);
margin-left:-5px;
margin-top:-5px;
position:relative;
&.s {
@for $column from 1 through 12 {
@for $row from 1 through 24 {
&#{$column}x#{$row} {
.grid {
-ms-grid-columns: 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr;
-ms-grid-rows: 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr;
grid-template-columns: repeat($column, calc((100% / #{$column})));
grid-template-rows: repeat($row, calc((100% / #{$row})));
grid-column-gap: 0px;
grid-row-gap: 0px;
}
}
}
}
}
}
Now, I'm trying to figure out how to make the -ms-grid-columns
and -ms-grid rows
dynamic. Right now, it's just built for a 12x12 grid, but I want them to have the correct number of fr
units depending on the outputted grid size.
I found out LESS has a merge
function that would work perfectly, but I don't know what that is in SASS
css sass
I'm writing some SASS to output several column/row combinations for a grid. It works fine in modern browsers because they all know how to use CSS' repeat()
function. But of course, I have to develop for IE11 and Edge...
I have this function that outputs all combinations between 1-12 columns and 1-24 rows (yes, it's a lot of output, but it's necessary).
.grid-container {
width:calc(100% + 10px);
margin-left:-5px;
margin-top:-5px;
position:relative;
&.s {
@for $column from 1 through 12 {
@for $row from 1 through 24 {
&#{$column}x#{$row} {
.grid {
-ms-grid-columns: 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr;
-ms-grid-rows: 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr 12fr;
grid-template-columns: repeat($column, calc((100% / #{$column})));
grid-template-rows: repeat($row, calc((100% / #{$row})));
grid-column-gap: 0px;
grid-row-gap: 0px;
}
}
}
}
}
}
Now, I'm trying to figure out how to make the -ms-grid-columns
and -ms-grid rows
dynamic. Right now, it's just built for a 12x12 grid, but I want them to have the correct number of fr
units depending on the outputted grid size.
I found out LESS has a merge
function that would work perfectly, but I don't know what that is in SASS
css sass
css sass
edited Nov 9 at 15:57
asked Nov 7 at 18:19
ntgCleaner
4,09022755
4,09022755
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195478%2fsass-css-repeat-variable-in-for-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown