flex布局:解决justify-content: space-between;最后一行靠左对齐

2022-08-02,,,,

场景:使用flex布局,每列数量不固定自适应,元素间距自适应,两端对齐

问题:最后一行元素不够时,会变成左右,如图

解决方法:放置占位元素,占位元素宽度与其他元素宽度一直,高度为0,

<!-- // 占位元素 -->
<div class="data-item temp" v-for="i in 6" :key="i"></div>
&.temp {
          height: 0;
          margin-bottom: 0;
          border: none;
          padding: 0;
        }

 

感觉不够可以多循环几个,没啥影响.

结果:    

完美

本文地址:https://blog.csdn.net/gouwa626/article/details/107379144

《flex布局:解决justify-content: space-between;最后一行靠左对齐.doc》

下载本文的Word格式文档,以方便收藏与打印。