Center image in div

Submitted by:Jhon Brain

Date added:13 April, 2014

Category:CSS

CSS code to center image in div with overflow hidden

Tags: center image , div image , overflow

Code Snippet:

HTML: 
<div class="ImgWrapper">
<a href="#"><img class="CropCenter" src="img.png"></a>
</div>

CSS:

div.ImgWrapper {
width: 160px;
height: 160px
overflow: hidden;
text-align: center;
}

img.CropCenter {
left: 50%;
margin-left: -100%;
position: relative;
width: auto !important;
height: 160px !important;
}
 
 

Comments