我了解使用BEM时,类名不应直接反映HTML结构,但应该如何命名包装元素?请忽略我的特定语法(接近SUIT);它仍然遵循BEM,只是用一种不同的方式来区分元素。

例如:

<div class="?">
  <footer class="PageFooter">
    <h4 class="PageFooter-brand>…</h4>
    <ul class="PageFooter-contactDetails">…</ul>
  </footer>
<div>

我目前在这种情况下将包装器归类为PageFooterWrapper,但是这感觉很笨拙,因为包装器不是独立的-它仅存在于PageFooter中。显然,所有内容都以PageFooter-开头是荒谬的,因此只剩下将包装器作为PageFooter:PageFooter-wrapper的一部分。这使我很恼火,因为这暗示了一个暗示。

那么包装器的类别应该是什么?

最佳答案

我一直对待包装的方式应该始终是块,因此:

<div class="PageFooter">
  <footer class="PageFooter-inner">
    <h4 class="PageFooter-brand">...</h4>
    <ul class="PageFooter-contactDetails">...</ul>
  </footer>
</div>

B 锁包含 E 元素,因此我没有遵循我的 B 锁,而是遵循 E 元素原理,开始使用inner而不是容器

08-04 18:29