I have a div that contains an image and text. I'm trying to simply vertically align the text.
I've tried setting vertical-align: center;
and line-height:90px
, but neither seem to be having any effect.
If I remove the image, even just line-height:90px
does the job, so I suspect it's something to do with the image affecting the baseline of the div.
If possible I'd prefer solutions without flexbox.
My code:
.menubuttons{
height:90px;
background-color: red;
font-size:30px;
/*my unsuccessful attempt at centering the text vertically*/
vertical-align: middle;
line-height:90px;
}
.menubuttons img{
height:50px;
margin:20px;
}
<div class="menubuttons"><img src='https://cdn-icons-png.flaticon.com/512/2111/2111806.png'/>Stack Overflow</div>