SASS For Loop including 0 -


i have loop in sass loops through page classes insert colour break each module. example:

@for $i 1 through 4 { // loop     .m0#{$i} .module-title{     background-color: nth($m_col_lvl_01_list, $i);     } //- end loop } 

which compiles to:

.m01 .module-title{     background-color: green; } .m02 .module-title{     background-color: blue; } .m03 .module-title{     background-color: yellow; } .m04 .module-title{     background-color: orange; } 

in task have @ moment includes .m00 there way of including 00 in loop?

i think can still achieve want using 0 in loop.

$list: (green, blue, orange, red, yellow);  //loop 0 length of list isn't hardcoded @for $i 0 length($list) {     .m0#{$i} .module-title {         //simply add 1 loop index correct list item         background-color: nth($list, $i + 1);     } } 

this compiles following css

.m00 .module-title {   background-color: green; }  .m01 .module-title {   background-color: blue; }  .m02 .module-title {   background-color: orange; }  .m03 .module-title {   background-color: red; }  .m04 .module-title {   background-color: yellow; } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -