看看這個例子:SASS/SCSS對象鍵值環
@include font-face('Entypo', font-files('entypo.woff'));
.icon {
display: inline;
font: 400 40px/40px Entypo;
}
.icon-star {
@extend .icon;
&:after {
content: "\2605";
}
}
.icon-lightning {
@extend .icon;
&:after {
content: "\26A1";
}
}
我希望讓事情儘可能的乾燥,所以我想知道如果下面是可能的,如果是的話怎麼辦?
@include font-face('Entypo', font-files('entypo.woff'));
.icon {
display: inline;
font: 400 40px/40px Entypo;
}
$icons {
$star: "\2605";
$lightning: "\26A1";
}
@each $icon in $icons {
$key = $icon{key}; // ???
$value = $icon{value}; // ???
.icon-#{$key} {
@extend .icon;
&:after {
content: $value;
}
}
}
我討厭SASS的文件,無論如何,非常感謝。 – onlineracoon
如果你想在http://learnboost.github.io/stylus/ –
完美的例子 – lorless