I have two rows containing Now I want the last item in each row (with How do I include thisdisplay: flex;
, each row contains several sub6/3
. In the second row there are 4 items and their proportion is2/2/2/3
.
flex: 3;
) to be perfectly aligned unless I add agap: X px;
.
gap
in the calculation so that items with the same width align according to theirflex
property? Or simplify it graphically in the following code snippet: How do I align the red border?.flex { height: 50px; display: flex; gap: 20px; // <- 破坏我的布局的罪魁祸首 } .item { background-color: green; outline: 1px solid black; display: flex; justify-content: center; align-items: center; } .item-2 { flex: 2; } .item-3 { flex: 3; } .item-6 { flex: 6; }
One of the many possible solutions is to wrap some items in another flex div.
See the code below, which contains class
flex-item
: