JSFiddle - React, Tailwind, and code Playground
HTML
<div id="flexbox">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div id="grid">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
CSS
#flexbox{
display:flex;
flex-flow: row wrap;
height:30vh;
width:30vw;
background:black;
padding:5px;
margin:5px;
}
#flexbox > div{
height:40px;
width:40px;
background:purple;
margin:5px;
}
#grid{
display:grid;
grid-template-columns: repeat(auto-fill, 40px);
grid-gap: 10px;
height:30vh;
width:30vw;
background:black;
padding:5px;
margin:5px;
}
#grid > div{
height:40px;
/*width:40px;*/
background:purple;
}
JavaScript
var GetItemOfContainer = function (container, rIdx, cIdx) {
// solution code here
}