0

正如在 BEM 方法中更好的 Nativity 元素嵌套在元素中一样
,我有以下标记:

 <table class="product-list">
                        <tr>
                          <th>Your Items</th>
                          <th>Price</th>
                          <th>Qty</th>
                          <th>Remove</th>
                        </tr>
                        <tr>
                          <div class="product-list__wrapper-img"><img src="./images/mini-cart/1.jpg"></div>
                        </tr>
                      </table>

我有一个块.product-list,它有元素.product-list__wrapper-img,里面有一张图片<img src="./images/mini-cart/1.jpg"> 对我放置的块进行样式化

.product-list{
  width: 680px
}

.product-list__wrapper-img{
  position:relative;
  z-index:0;
  width: 77px;
  height: 90px
}

.product-list__wrapper-img img {
  position: absolute
  z-index: 1
  top: 50%
  left: 50%
  transform: translate(-50%, -50%)
  max-width: 98%
  max-height: 98%
}

我知道好像是在BEM中给tags联系是不可取的,ie,所以好像不可能写

.product-list__wrapper-img img{
}

但是什么时候给 img 类设置样式,以及是否在 BEM 中,成为元素中的元素。我知道修饰符可以,但我知道的元素。我想我需要给这张照片打电话, .product-list__img也许 .product-list__wrapper-img__img 我会很高兴在这件事上有任何帮助。

4

1 回答 1

1

恕我直言:

<table class="product-list">
    <tr>
        <td>
            <div class="product-list__wrapper-img">
                <img class="product-list__img" src="./images/mini-cart/1.jpg">
            </div>
        </td>
    </tr>
</table>

或者:

<table class="product-list">
    <tr>
        <td class="product">
            <div class="product__wrapper">
                <img class="product__img" src="./images/mini-cart/1.jpg">
            </div>
        </td>
    </tr>
</table>
于 2015-09-03T17:48:55.800 回答