After reviewing this repository here, it appears that you can implement the following CSS in your code:
CSS:
* {
box-sizing: border-box;
}
.flexContainer {
display: flex;
flex-wrap: wrap;
}
.flexContainer .item {
padding: 5px;
flex: 1 1 20%;
}
This will help achieve the intended layout.
* {
box-sizing: border-box;
}
.flexContainer {
display: flex;
flex-wrap: wrap;
}
.flexContainer .item {
padding: 5px;
flex: 1 1 20%;
}
.flexContainer .item a {
display: block;
background: blue;
text-align: center;
}
<div class="flexContainer">
<div class="item"><a href="">sdfsf</a></div>
<div class="item"><a href="">dffdfdf</a></div>
<div class="item"><a href="">fdfdfd</a></div>
<div class="item"><a href="">fdfdgdf</a></div>
<div class="item"><a href="">ffffffffff</a></div>
<div class="item"><a href="">fdfdfdg</a></div>
<div class="item"><a href="">dddddddddddddd</a></div>
<div class="item"><a href="">fdfdfdsd</a></div>
<div class="item"><a href="">dsds</a></div>
<div class="item"><a href="">dffdfdfdsf</a></div>
<div class="item"><a href="">dffdfdfsdsds</a></div>
<div class="item"><a href="">dffdfdfssdsfd</a></div>
<div class="item"><a href="">dfsddfdfdf</a></div>
<div class="item"><a href="">dff</a></div>
<div class="item"><a href="">dffdfdfdffdfdfdffdfdf</a></div>
</div>
UPDATE 14-JULY-2017 0829 UTC
To demonstrate limiting to 5 items per row using this method, while adjusting according to content width:
* {
box-sizing: border-box;
}
.flexContainer {
display: flex;
flex-wrap: wrap;
}
.flexContainer .item {
padding: 5px;
flex: 1 1 20%;
}
.flexContainer .item a {
display: block;
background: blue;
text-align: center;
}
<div class="flexContainer">
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we are a bit bigger</a></div>
<div class="item"><a href="">we are a bit bigger</a></div>
<div class="item"><a href="">we are a bit bigger</a></div>
<div class="item"><a href="">we are a bit bigger</a></div>
<div class="item"><a href="">we are quite a bit bigger</a></div>
<div class="item"><a href="">we are quite a bit bigger</a></div>
<div class="item"><a href="">we are quite a bit bigger</a></div>
<div class="item"><a href="">we are the biggest divs yet</a></div>
<div class="item"><a href="">we are the biggest divs yet</a></div>
<div class="item"><a href="">I am the daddy of all the divs on this page.</a></div>
</div>
UPDATE 18-OCT-2019 1909 UTC
Following best practices, it is recommended to use slightly less than available capacity to account for gaps. Here is the updated code:
* {
box-sizing: border-box;
}
.flexContainer {
display: flex;
flex-wrap: wrap;
}
.flexContainer .item {
padding: 5px;
flex: 1 1 17%;
}
.flexContainer .item a {
display: block;
background: blue;
text-align: center;
}
<div class="flexContainer">
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we're short</a></div>
<div class="item"><a href="">we are a bit bigger</a></div>
<div class="item"><a href="">we are a bit bigger</a></div>
<div class="item"><a href="">we are a bit bigger</a></div>
<div class="item"><a href="">we are a bit bigger</a></div>
<div class="item"><a href="">we are quite a bit bigger</a></div>
<div class="item"><a href="">we are quite a bit bigger</a></div>
<div class="item"><a href="">we are quite a bit bigger</a></div>
<div class="item"><a href="">we are the biggest divs yet</a></div>
<div class="item"><a href="">we are the biggest divs yet</a></div>
<div class="item"><a href="">I am the daddy of all the divs on this page.</a></div>
</div>