2011-10-08 73 views
0

我試圖與LessCss功能,但我得到一個錯誤:LessCss RGBA和@vars

.transparent-border (@alpha:.15, @color:'0,0,0', @type: solid, @size:1px) { 
    @val: @size @type rgba(@color, @alpha); 
    border: @val; 
} 

錯誤
錯誤評估函數rgba
@val:@size @type rgba(@color, @alpha);

我該如何解決?

回答

2

使用此代碼來代替:

.transparent-border (@alpha:.15, @r:0, @g:0, @b:0, @type: solid, @size:1px) { 
    @val: @size @type rgba(@r, @g, @b, @alpha); 
    border: @val; 
} 

它不僅工作,但它也更有意義。在以前的嘗試,你就必須通過一個字符串的顏色:

#myElement{ 
    /*Old, not-working implementation*/ 
    .transparent-border (0.15, "0, 0, 0", solid, 1px); 

    /*New, neat and working method */ 
    .transparent-border (0.15, 0, 0, 0, solid, 1px); 

    /*Since these are the default settings, it's equivalent to*/ 
    .transparent-border 
} 

解析的LESS:

#myElement { 
    border: 1px solid rgba(0,0,0, 0.15); 
}