浏览Twitter Bootstrap的2.0-wip分支,我发现很少有绑定变量和混合的好方法。参见下面的示例代码:
#font {
#family {
.serif() {
font-family: Georgia, "Times New Roman", Times, serif;
}
.sans-serif() {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.monospace() {
font-family: Menlo, Monaco, Courier New, monospace;
}
}
.shorthand(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
font-size: @size;
font-weight: @weight;
line-height: @lineHeight;
}
.serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
#font > #family > .serif;
#font > .shorthand(@size, @weight, @lineHeight);
}
.sans-serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
#font > #family > .sans-serif;
#font > .shorthand(@size, @weight, @lineHeight);
}
.monospace(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
#font > #family > .monospace;
#font > .shorthand(@size, @weight, @lineHeight);
}
}与此对应的SCSS是什么?如何在SCSS中重写上述内容?
发布于 2012-01-04 04:56:58
不幸的是,这是目前SCSS中缺少的特性之一(据我所知)。这个问题的答案是:没有等同于SCSS的。您必须以与SCSS兼容的方式重写它。例如,看看我在SCSS Twitter Bootstrap fork中的重写(使用了你提到的那个例子)。
另外,不要使用那个分支,它现在还没有维护,你最好使用官方Twitter Bootstrap的wiki中提到的那个分支。(details)
https://stackoverflow.com/questions/8687049
复制相似问题