別の選択肢を追加したかっただけです。Bootstrap の LESS を使用している場合は、ミックスインも使用できます。
Bootstrap の LESS フォルダー( bootstrap > less > mixins
)の中を見ると、buttons.less
ファイルが表示されます。それを開くと、ミックスインが見つかります.button-size()
。
ミックスインは次のとおりです。
.button-size(
vertical padding;
horizontal padding;
font size;
line height;
border-radius
);
ボタンを動的に作成する方法は次のとおりです。
特定のパラメーターを渡す必要があります。1つ欠けるとブレーキがかかります
.button-size(10px; 10px; 1em; 1.5em; 0);
既存の Bootstrap LESS 変数を使用した例を次に示します。
.btn {
@media (min-width: @screen-sm-min) {
.button-size(
@padding-small-vertical;
@padding-small-horizontal;
@font-size-small;
@line-height-base;
@border-radius-small
);
}
@media (min-width: @screen-md-min) {
.button-size(
@padding-large-vertical;
@padding-large-horizontal;
@font-size-large;
@line-height-base;
@border-radius-large
);
}
}