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










share|improve this question




























    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










    share|improve this question


























      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










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 15:57

























      asked Nov 7 at 18:19









      ntgCleaner

      4,09022755




      4,09022755





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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





















































          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







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini