I\'m trying to use both the css property object-fit: cover
on an img
element to have my image filling its containing div
and tra
After testing it seems that backface-visibility
, translateZ
, and translate3d
which are required to prevent the transform flicker, break object-fit
and background-size
. If your goal is to center the image then you can use position: absolute
and translate
like in the example below.
div.category {
width: 80%;
height: 150px;
margin: 20px;
position: relative;
overflow: hidden;
}
img {
display: block;
width: 100%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(1.12); /* order is important here*/
backface-visibility: hidden;
transition: transform 0.35s;
}
div.category:hover img {
transform: translate(-50%, -50%) scale(1);
}
http://jsfiddle.net/moogs/r1s1rtLk/4/