多個值也可以用 @each 指令中使用。如, $var1, $var2,$var3, ... 在 <list>.
@each $var1, $var2, $var3 ... in <list>
$var1, $var2 和 $var3: 這些代表變數的名稱。
<list>: 它代表列表的列表,每個變數將持有子列表的元素。
<html> <head> <title>Control Directives & Expressions</title> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <body> <p class="aqua">This is line one.</p> <p class="red">This is line two.</p> <p class="green">This is line three.</p> </body> </html>
@each $color, $border in (aqua, dotted), (red, solid), (green, double){ .#{$color} { background-color : $color; border: $border; } }
sass --watch C:\Ruby22-x64\style.scss:style.css
.aqua { background-color: aqua; border: dotted; } .red { background-color: red; border: solid; } .green { background-color: green; border: double; }