I am trying to create a 2x2 grid with a div. Some of the divs may contain an image, but it will probably be set as the background, with an option background-size: cover.
Here is the pen I created: http://codepen.io/qarlo/pen/vLEprq
.container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin: auto;
max-width: 960px;
width: 80%;
}
.container__item {
align-content: center;
border: 1px solid #333;
display: flex;
flex-basis: 1;
font-size: 3em;
justify-content: center;
height: 100%;
margin-bottom: 1em;
min-height: 300px;
width: 47%;
}
<div class="container">
<div class="container__item">?</div>
<div class="container__item">?</div>
<div class="container__item">?</div>
<div class="container__item">?</div>
</div>
Run codeHide resultI would like to make divs be squares and maintain proportions when resizing. I mistakenly hoped that this would be easy with flexbox, but if I didn’t miss something, I was mistaken.
source
share