我做了以下兩種混合類型:使用LESS變量作爲一個屬性,而不是一個價值
.responsive_color(@color, @response_color, @speed: 0.1s){
color: @color;
.transition(color, @speed);
&:hover, &:active, &:focus{
color: @response_color;
}
}
.responsive_background(@color, @response_color, @speed: 0.1s){
background-color: @color;
.transition(background-color, @speed);
&:hover, &:active, &:focus{
background-color: @response_color;
}
}
由於這兩個幾乎相同我想將它們合併爲這樣的事情:
.responsive(@property, @color, @response_color, @speed: 0.1s){
@property: @color;
.transition(@property, @speed);
&:hover, &:active, &:focus{
@property: @response_color;
}
}
雖然這不會導致LESS解析器(PHP類)中的錯誤,但它會被忽略。 我也嘗試過@ {property}和'@ {property}',但這兩個都會導致錯誤。
有誰知道我可以輸出@property來正確解析? 或者我想做一些不可能的事情?
糟糕的是它必須是黑客,但很高興知道它在議程中。直到那個時候,我才能忍受黑客攻擊。 非常感謝! – SanderVerkuijlen