@each $var1, $var2 in <map>
$var1, $var2: 這些代表變數的名稱
<map>: 它表示列表對
<html> <head> <title>Control Directives & Expressions</title> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <body> <h1>Welcome to Yiibai</p> <h2>Welcome to Yiibai</p> <h3>Welcome to Yiibai</p> </body> </html>
@each $header, $color in (h1: red, h2: green, h3: blue) { #{$header} { color: $color; } }
sass --watch C:\Ruby22-x64\style.scss:style.css
h1 { color: red; } h2 { color: green; } h3 { color: blue; }