I am trying to achieve a classy zoom in effect on a div's background image with background-size:cover using transform:scale.
The problem I am facing is that the scale seems to enlarge the div as the background-image zooms in.
Is there a way to only apply the effect to the background image? Or am I doing something wrong?
.despre-noi-image {
width: 40%;
height: 500px;
background: url('https://static.independent.co.uk/s3fs-public/styles/story_large/public/thumbnails/image/2017/04/18/16/wine-evening.jpg') no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
text-align: left;
background-position-x: 50%;
background-position-y: 0%;
-webkit-animation: zoomin 10s linear;
animation: zoomin 10s linear;
animation-fill-mode: forwards;
}
@-webkit-keyframes zoomin {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(2);
transform: scale(2);
}
}
<div class="despre-noi-image">
</div>
<!-- despre-noi-image -->
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…