我开始使用BEM方法论[BLOCK, ELEMENT, MODIFIER],但是我有疑虑。
在一个名为“参与”的部分中,我有一个表单,因此:
<section class="participate">
<form class="participate__form">
<label for="name" class="participate__form__label"></label>
<input type="text" id="name" name="participate__form__input"/>
</form>
</section>
以下是CSS代码:
.participate {
&__form {
// css here
}
&__form__label {
// css here
}
&__form__input {
// css here
}
}
表单内的类太多了,所以建议将其嵌套一层:
<section class="participate">
<form class="participate__form form">
<label for="name" class="form__label"></label>
<input type="text" id="name" name="form__input"/>
</form>
</section>
但是我应该如何为它设置样式呢?
我是这样使用它的:
.participate {
.form {
// CSS HERE
&__label {
// CSS HERE
}
&__input {
// CSS HERE
}
}
}
但我真的相信这不是正确的方法。请问,有人可以在这里给我一些提示吗?