How to add a column to a row according to conditions

when index is even, add a Col to the newly generated Row when Row,index is odd


Mar.22,2021

you can also add one per click and use css to wrap


you want to be complicated, and there are two ways to do it:

  1. determine whether it is an odd number or an even number when each click is increased. If it is odd, it will be added directly after it. If it is even, it will be displayed in a new line.
  2. fixed container width, and then each increase in item width is also fixed, 50% of the container width, so that each line can only put two item, and then increase, there will naturally be the effect of line wrapping
Menu