Flex layout, and how to set the width of the warp, parent layer adaptively?

.flex{
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  border: 1px solid green;
}

.item{
  margin-bottom: 5px;
  margin-right: 5px;
  background: pink;
  width: 70px;
  height: 50px;
  line-height: 50px;
  text-align: center;
}

 <div class="flex">
   <div class="item">
   </div>
   <div class="item">
   </div>
   ...
 </div>

how the width of the parent layer DIV is not left blank after the line wrapping

Mar.06,2021

use flex: justify-content:space-between;
or refer to this:

this may help you: https://github.com/shaozj/blo.

Menu