JSFiddle - React, Tailwind, and code Playground
by RaphaelDDL
HTML
<div class="container clearfix">
<div class="child">1</div>
<div class="child">2</div>
<div class="child">3</div>
<div class="child">4</div>
</div>
CSS
.container {
background: red;
padding: 10px;
position:fixed;
display:flex;
flex-wrap:wrap;
}
.child {
width: 100px;
height: 100px;
/* float: left; */
flex: 1 1 auto;
margin: auto;
}
.child:nth-child(even) {
background: green;
}
.child:nth-child(odd) {
background: blue;
}
.clearfix:after {
content: "";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}