I'm trying to center my text vertically in my divs, but I'm using display: flex
so I can't use display: table
.
What's the best way to vertically center the text here, ideally without adding lots of html elements (hoping to keep the 'thing' divs as clean as possible)?
.container {
height: 100vh;
width: 100vw;
display: flex;
flex-wrap: wrap;
}
.thing {
background: red;
color: white;
margin: 5px;
text-align: center;
display: table;
flex: 1 0 30%;
vertical-align: middle;
}
<div class="container">
<div class="thing">
text
</div>
<div class="thing">
text
</div>
<div class="thing">
text
</div>
<div class="thing">
text
</div>
</div>