2014-03-03 100 views
0

當我試圖創建一個使用SASS @mixin和@for指令一些CSS選擇器,@for不工作是這樣的:SASS/SCSS @mixin使用參數

$colors: $comedy, $drama, $thriller, $scifi; 
$color-names: comedy, drama, thriller, scifi; 

@mixin taxonomy-color($property) { 
    @for $i from 1 through length($color-names) { 
    .#{nth($color-names, $i)} { 
     background-color: nth($colors, $i); 
    } 
    } 
} 

@include taxonomy-color(background-color); 

以上的作品,但是當我將background-color: nth($colors, $i);更改爲$property: nth($colors, $i); CSS編譯時沒有錯誤,但是我沒有從這個mixin輸出。誰能告訴我爲什麼我的邏輯有問題?我正在使用SASS 3.3.0.rc.2。

回答

0

只是插值$property ...

@mixin taxonomy-color($property) { 
    @for $i from 1 through length($color-names) { 
    .#{nth($color-names, $i)} { 
     #{$property}: nth($colors, $i); 
    } 
    } 
} 

DEMO