1 回答

TA貢獻1998條經驗 獲得超6個贊
這完全取決于主題之間有多少種樣式和變量,例如(非常)基本的凝視點可能是這樣的:
@主題:
藍色RGB(41,128,185),
海洋rgb(22,160,133),
綠色rgb(39,174,96),
橙色rgb(211,84,0),
紅色RGB(192,57,43),
紫色RGB(142,68,173);
//用法:
#navBar {
.themed(background-color);
}
//實現:
@import “為” ;
.themed(@property){
.for(@themes); .-each(@theme){
@name:提?。ˊtheme,1);
@color:提?。ˊtheme,2);
.theme-@ {name}和{
@ {屬性}:@color;
}
}
}
然后使用模式匹配,規則集參數等,您可以自動生成任何復雜的外觀/主題層次結構。
例如幾乎相同的簡單示例,但具有更多可定制的方法:
// usage:
#navBar {
.themed({
color: @fore-color;
background-color: @back-color;
});
}
// themes:
.theme(@name: green) {
@fore-color: green;
@back-color: spin(@fore-color, 180);
.apply();
}
.theme(@name: blue) {
@fore-color: blue;
@back-color: (#fff - @fore-color);
.apply();
}
.theme(@name: black-and-white) {
@fore-color: black;
@back-color: white;
.apply();
}
// etc.
// implementation:
.themed(@style) {
.theme(); .apply() {
.theme-@{name} & {
@style();
}
}
}
- 1 回答
- 0 關注
- 610 瀏覽
相關問題推薦
添加回答
舉報