使用el-space问题

有没有智能的方法去掉el-space遗留的问题

img


把每一个最右边的空去掉,不然看起来很难看,空那么多

    <el-space size="large" wrap >
          <template v-for="(item,index) in formWorks">
              <img :src="item.imgUrl" alt="" style="height: 125px;" @click="activeHandle(item)">
          </template>
        </el-space>

el-space 组件是基于 flex 布局实现的,所以在使用时需要将其包裹的元素设置为 display: flex 或者 display: inline-flex。

el-space 组件默认会在最后一个元素之后留下空白,可以通过设置 justify 属性来控制最后一个元素的对齐方式,例如:


<el-space size="large" wrap justify="start">
  <template v-for="(item,index) in formWorks">
    <img :src="item.imgUrl" alt="" style="height: 125px;" @click="activeHandle(item)">
  </template>
</el-space>

其中,justify 属性可以设置最后一个元素的对齐方式,取值范围为 start、end、center、space-between 和 space-around。

如果以上两点都已经注意到了,但仍然存在 el-space 组件留下空白的问题,可能需要检查一下父元素的宽度是否足够容纳所有子元素,或者使用浏览器的开发者工具查看是否存在其他的 CSS 样式影响了布局。

希望可以帮助到您

计算下,然后使用class控制css复写原来css