I want to show 5 items per row using flexbox.
.parent-wrapper {
height: 100%;
width: 181px;
border: 1px solid black;
}
.parent {
display: flex;
font-size: 0;
flex-wrap: wrap;
margin: -10px 0 0 -10px;
}
.child {
display: inline-block;
background: blue;
margin: 10px 0 0 10px;
flex: 1 1 calc(100% * (1/5) - 10px - 1px);
height: 100px;
}
<body>
<div class="parent-wrapper">
<div class="parent">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
</div>
</body>
I want to use the flex grow, so that resize will not affect the data displayed. This code above will stretch the data if the row less than 5 items. If i didnt use the flex grow, it works fine for the view, but when resizing there will show some blank space after the data displayed.
If without flex grow, how can i consume extra space by just using the flex basis
calc(100% * (1/5) - 10px - 1px)