Take a look at the code snippet below:
.flex-container {
padding: 20px;
margin: 20px;
list-style: none;
border: 1px solid silver;
-ms-box-orient: horizontal;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
justify-content: space-evenly;
}
.wrap {
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
}
.wrap li {
background: gold;
}
.flex-item {
border: 1px solid blue;
background: tomato;
padding: 5px;
width: 100px;
height: 100px;
margin: 10px;
line-height: 100px;
color: white;
font-weight: bold;
font-size: 2em;
text-align: center;
}
<ul class="flex-container wrap">
<li class="flex-item">1</li>
<li class="flex-item">2</li>
<li class="flex-item">3</li>
<li class="flex-item">4</li>
<li class="flex-item">5</li>
<li class="flex-item">6</li>
<li class="flex-item">7</li>
<li class="flex-item">8</li>
<li class="flex-item">9</li>
</ul>
I'm looking for some help: Is there a way to use flexbox to ensure that only three boxes are displayed in one row while maintaining their original widths? I want to evenly distribute the remaining space, accommodating a total of nine boxes in three rows with three boxes each. How can this layout be achieved using flexbox?