I have an image that's in an anchor element.
I want the anchor an the image to be centered both vertically and horizontally in the parent div.
Here's an example:
<div class="wrapper">
<a href="#" class="anchor">
<img src="http://bit.ly/1mFH8AW"></img>
</a>
</div>
.wrapper {
background: black;
width: 500px;
height: 500px;
}
.anchor {
}
.anchor > img {
height: 100px;
width: 100px;
}
Result:
Add
position:relative
to your wrapper and then change the image's CSS to:jsFiddle example