I'm trying to vertically center an image in a div in an <a>
tag but I can't get the CSS to vertically center the image for the life of me.
div {
height: 7rem;
width: 90%;
text-align: center;
margin: 1.25rem auto;
padding: 0 5.5rem 0 5.5rem;
font-size: .8rem;
border-style: solid;
border-width: .08rem;
}
div * {
position: relative;
top: 50%;
transform: translateY(-50%);
}
div img {
width: 4rem;
}
div div {
margin: 0 auto;
width: 4rem;
height: 100%;
}
<div class="footer">
<div id="footerhome">
<a href="https://www.google.com">
<img src="http://images.clipartpanda.com/smiley-face-transparent-background-tumblr_mdv6nltwdB1qdic05o1_500.gif" />
</a>
</div>
</div>
This is what I'm currently working with: http://codepen.io/SamanthaBae/pen/LRomdr
I've tried the solution of making the image the background image of the div it's contained in and inserting the <a>
tag in between, but it doesn't seem to work as a link, even though I can get it to vertically align:
I have checked here and here as resources, but have not been able to apply their methods in this case.