Skip to content

Instantly share code, notes, and snippets.

@YuraKolesnikov
Created November 17, 2018 12:41
Show Gist options
  • Save YuraKolesnikov/40f5cf5e2a473ff347acd63e6f849bdc to your computer and use it in GitHub Desktop.
Save YuraKolesnikov/40f5cf5e2a473ff347acd63e6f849bdc to your computer and use it in GitHub Desktop.
Div animation on hover
/* Container styling */
.container {
position: relative;
width: 360px;
height: 640px;
margin-top: 150px;
background: rgba(0,0,0,0);
transform: rotate(-30deg) skew(25deg) scale(.8);
transition: all .5s ease;
}
.container img {
position: absolute;
width: 100%;
transition: .5s ease;
}
.container:hover img:nth-child(5) {
transform: translate(160px, -160px);
opacity: 1;
}
.container:hover img:nth-child(4) {
transform: translate(120px, -120px);
opacity: .8;
}
.container:hover img:nth-child(3) {
transform: translate(80px, -80px);
opacity: .6;
}
.container:hover img:nth-child(2) {
transform: translate(40px, -40px);
opacity: .4;
}
.container:hover img:nth-child(1) {
opacity: .2;
}
<div class="container">
<img src="img.jpg" alt="">
<img src="img.jpg" alt="">
<img src="img.jpg" alt="">
<img src="img.jpg" alt="">
<img src="img.jpg" alt="">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment