【发布时间】:2014-04-06 01:31:31
【问题描述】:
这是在 Bootstrap 中设置按钮样式的方式:
<button class="btn btn-default">Do Something</button>
必须应用两个类才能获得一个按钮。我在 Bootstrap 的其他部分也看到了类似的模式:
<i class="glyphicon glyphicon-ok">
我想减少在我的 HTML 中使用的类的数量。一种方法是使用 less 混合:
.btn-default {
.btn;
.btn-default;
}
.glyphicon-ok {
.glyphicon;
.glyphicon-ok;
}
那么我的HTML可以简化成这样:
<button class="btn-default">Do Something</button>
<i class="glyphicon-ok">
这是个好主意吗?将普通类(.btn、.glyphicon)与特定类(.btn-default、.glyphicon-ok)结合起来,我是否会失去一些东西?
【问题讨论】:
标签: html css twitter-bootstrap twitter-bootstrap-3