Center image inside div with overflow hidden

HTML:

<div class="outer">
    <div class="inner">
        <img src="" alt="" />
    </div>
</div>

CSS:

.outer {
    width: 400px;
    overflow: hidden;
}

.inner {
    display: inline-block;
    position: relative;
    right: -50%;
}

img {
    position: relative;
    left: -50%;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *