2014-02-14 33 views
1

在SCSS嵌套属性,与普通前缀特性可以描述为嵌套属性。因此,在example与普通缀

.funky{ 
    font: 2px/3px{ 
    family: fantasy; 
    size: 30em; 
    weight: bold; 
    } 
} 

被编译为:

.funky{ 
    font: 2px/3px; 
    font-family: fantasy; 
    font-size: 30em; 
    font-weight: bold; 
} 

我该怎么做与普通贴上性质类似的事情?我怎样才能编写一个嵌套的属性,将编译为:

.funky{ 
    color: red; 
    background-color: green; 
    border-color: blue; 
} 

回答

2

萨斯没有这样的概念构造。你必须修补它或写一个详细的mixin做到这一点。

@mixin color($background: null, $border: null, $font: null) { 
    background-color: $background; 
    border-color: $border; 
    color: $font; 
} 

.foo { 
    @include color($background: green, $font: red); 
} 
+0

'@include color($ background:green,$ font:red);'看起来不太好。是否有可能通过类似的哈希或关键字参数? – sawa

+0

OK,我意识到,SASS关键字参数需要'$'。谢谢您的帮助。 – sawa