Is there a way to center an img
within a parent div
tag that has overflow: hidden
set? I am looking to clip the image equally on both sides in order to display the middle portion.
<div class='wrapper'>
<img/>
</div>
The desired styling would be:
.wrapper {
position: absolute;
/* add positioning details here */
overflow: hidden;
}
.wrapper img {
height: 100%;
margin-left: -??; //what should go here?
}
Using -50%
as the width of the parent may not work, so how can we calculate the width of the img itself?
It's important that the solution is compatible with Firefox CSS standards.