2014-08-28 131 views
1
// Mixin 
.text-overflow() { 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
} 

當我們在代碼中使用這個mixin時,我們是否需要放置括號()?在LESS mixins中使用括號()

a.overflow { 
    .text-overflow(); 
    display: block; 
} 
+3

當調用混入,括號是可選的。在編寫mixin時,如果不想將mixin代碼作爲單獨的類輸出,可以使用大括號。 [來源](http://lesscss.org/features/#mixins-feature-not-outputting-the-mixin)。 – Harry 2014-08-28 12:20:37

回答

0

在所有類中都被認爲是mixin。有括號和不帶括號的區別在於不輸出任何CSS。

// Less file 
.no-output(){ 
    color: red; 
} 

.output { 
    color: blue; 
} 

// Outputs 
.output { 
    color: blue; 
}