User Tools

Site Tools


sasset:going_through_a_list_with_each

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sasset:going_through_a_list_with_each [2016/04/02 14:50] (current)
leo created
Line 1: Line 1:
 +|<- [[Looping through lists with @for]]|[[Working with the map data type]] ->|
  
 +@each
 +
 +<​code>​
 +$color-names:​ '​rouge',​ '​vert',​ '​bleu';​
 +$colors: $red, $green, $blue;
 +
 +@each $name in $color-names {
 +  $i: index($color-names,​ $name); // à quel index dans $color-names correspond $name
 +  .btn-#​{$name} {
 +  @extend %btn;
 +    background-color:​ nth($colors,​ $i);
 +  }
 +}
 +</​code>​
 +
 +La meilleure manière de procéder avec un nombre non connu (ou variable) d'​éléments ?
sasset/going_through_a_list_with_each.txt · Last modified: 2016/04/02 14:50 by leo