What I have here is a container with background color and it contains multiple items that automatically align themselves when the screen is shrank.
Example with full width: https://i.stack.imgur.com/UbxtP.png
But when I shrink the width of the browser: https://i.stack.imgur.com/wyzzA.png
.flex-container {
display: inline-flex;
flex-wrap: wrap;
background-color: DodgerBlue;
}
.flex-container > div {
background-color: #f1f1f1;
width: 100px;
margin: 5px;
text-align: center;
line-height: 75px;
font-size: 30px;
}
<!DOCTYPE html>
<html>
<body>
<div class="flex-container">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
</div>
</body>
</html>