bootstrap.lessファイルを編集して、すべてを次のようにカプセル化できます。
.bootstrap {
// CSS Reset
@import "reset.less";
// Core variables and mixins
@import "variables.less"; // Modify this for custom colors, font-sizes, etc
[...]
}
アップデート:
ブートストラップファイルはless&演算子を使用するため、例:
// list-group.less (bootstrap 3.0.0)
.list-group-item {
[...]
a& {
[...]
}
}
上記のコードをコンパイルすると、意味的に間違ったルールになり、プレフィックスが.bootstrapになりません。
a.bootstrap .list-group-item {
color: #555555;
}
a.bootstrap .list-group-item .list-group-item-heading {
color: #333333;
}
a.bootstrap .list-group-item:hover,
a.bootstrap .list-group-item:focus {
text-decoration: none;
background-color: #ecf0f1;
}
これを修正するには、以下を使用してブートストラップをコンパイルします。
$ lessc bootstrap.less | sed -e 's/\(.\+\).bootstrap \(.\+\)/.bootstrap \1\2/g' > output.css
これで、上記の行は次のようにコンパイルされます。
.bootstrap a .list-group-item {
color: #555555;
}
.bootstrap a .list-group-item .list-group-item-heading {
color: #333333;
}
.bootstrap a .list-group-item:hover,
.bootstrap a .list-group-item:focus {
text-decoration: none;
background-color: #f5f5f5;
}