I am working on css scaling on hover that I cannot completely nail. I think this can be done with help transform scale(), but I have the main flicker due to the fact that the focus is easily lost on hover. Not to mention that the effect that I want to achieve does not work well for a single image. So let me explain what I'm trying to do.
I have 2 phones overlapping each other. Ideally, the background should be less 10%to achieve a depth perception effect. When I am over what is in the background, it should appear in front and trade z-indexplaces, increase the scale to 100%, and reduce the other by 10%(again for the percentage effect).
The same effect will happen when I hang over the one that I sent back, he must return to the front, where he was before and so on.
I will accept Javascript, but I would prefer a clean CSS solution if jQuery / JS is not valid.
Here is the HTML
<div class="wrap">
<img class="elem" src="http://www.lotusmarketingsolutions.com/wp-content/uploads/2016/01/monsters-4.png" alt="" />
<img class="elem2" src="http://www.lotusmarketingsolutions.com/wp-content/uploads/2016/01/monsters-3.png" alt="" />
</div>
And CSS
@import url(https://fonts.googleapis.com/css?family=Roboto:400,500,700,300);
body {
background: #202020;
font-family: 'Roboto', sans-serif;
}
.wrap {
width: 50%;
margin: 0 auto;
position: relative;
}
.wrap img {
position: absolute;
top: 0;
left: 0;
width: 250px;
}
.elem {
margin-left: 130px;
margin-top: 20px;
}
.elem:hover {
zoom: 50%;
-ms-transform: scale(2, 3);
-webkit-transform: scale(2, 3);
transform: scale(2, 3);
}
.elem2:hover {
zoom: 150%;
-ms-transform: scale(1.1, 1.1);
-webkit-transform: scale(1.1, 1.1);
transform: scale(1.1, 1.1);
}
And CODEPEN
Thanks!
source
share