When using padding or margin with a vertical percentage value, it can be referenced by the width. A media query can be set to adjust rows from ten to five.
Here is an example down below or you can experiment in Codepen here
.flex-container {
background: rgb(63, 81, 181);
padding: 0;
margin: 0;
display: flex;
flex-wrap: wrap;
counter-reset: items
}
.flex-item {
background: tomato;
margin: 5px;
color: white;
font-weight: bold;
font-size: 2vw;
text-align: center;
max-width: calc(10% - 10px);
flex: 1 0 calc(10% - 10px);
/* can also be a flex container */
display: flex;
align-items: center;
justify-content: center;
}
.flex-item:before {/* stretch it to be a square */
content: '';
float: left;/* if not a flex child*/
padding-top: 100%;
}
.flex-item:after {
counter-increment: items;
content: counter(items)
}
@media screen and (max-width:800px) {
.flex-item {
max-width: calc(20% - 10px);
flex: 1 0 calc(20% - 10px);
}
}
<p>click for full page view</p>
<div class="flex-container">
...