How do I vertical align the text within a responsive box? I did for the image but it doesn't work for span, not sure why. Below is my half way done demo :
img{
width:20px;
}
div{
width:100px;
height:100px;
background:#ddd;
padding:10px;
}
img{
position: relative;
top: 50%;
transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
<div>
<img src="https://cdn2.iconfinder.com/data/icons/windows-8-metro-style/256/football.png"/>
<span>football</span>
</div>
Try This
img{
width:20px;
padding:2px;
}
div{
width:100px;
height:100px;
background:#ddd;
padding:10px;
}
img,span{
position: relative;
top: 50%;
transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
float: left;
}
Demo Here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With