我正在使用Twitter Bootstrap的样式,并且对继承有疑问。
我想创建两个标签类,它们可以继承Bootstrap中的标签样式。
.label-new {
.label; .label-important;
}
.label-updated {
.label; .label-warning;
}
然而,上述代码将导致LESS解析错误"NameError: .label-important未定义",因为.bootstrap中使用以下方式定义了.label-important和.label-warning:
.label,
.badge {
// Important (red)
&-important { background-color: @errorText; }
&-important[href] { background-color: darken(@errorText, 10%); }
// Warnings (orange)
&-warning { background-color: @orange; }
&-warning[href] { background-color: darken(@orange, 10%); }
}
是否有特殊的语法可以继承.label-important/warning样式?
提前致谢。
.label
将会给你.lable-new-important
和.label-new-warning
(等等)。我猜你只想要new
的important
属性和updated
的warning
属性,这是你的目标吗? - ScottS