mixinセレクター文字列を組み合わせることが可能かどうかを調べようとしています。私のコードのコンテキストではこれが可能だとは思いませんが、何かが欠けている可能性があります!
次のscssがあるとしましょう:
// Apply a set of rules to input form fields.
@mixin input-form-fields {
input:not([type="hidden"]),
textarea {
@content;
}
}
// Apply a set of rules to button form fields.
@mixin button-form-fields {
button, button {
@content;
}
}
// Apply a set of rules to select form fields.
@mixin select-form-fields {
select {
@content;
}
}
// Apply a set of rules to all form fields.
@mixin all-form-fields {
@include input-form-fields {
@content;
}
@include button-form-fields {
@content;
}
@include select-form-fields {
@content;
}
}
基本的に、all-form-fields mixin は他の mixin を呼び出し、異なるセレクターに対して同じルール セットを生成します。
次のコードをコンパイルすると:
@include all-form-fields {
margin-bottom: .5em;
}
私は次のようなものを得るでしょう:
input:not([type="hidden"]),
textarea {
margin-bottom: .5em;
}
button,
.button {
margin-bottom: .5em;
}
select {
margin-bottom: .5em;
}
これは理想的ではありません。これらのセレクターを組み合わせることができれば幸いです。
3 つの異なる mixin によって返されたセレクター文字列をどのように組み合わせることができるかについて、誰かアイデアはありますか?