Layered Image Hover Effects with HTML & CSS | Isometric Design

Web Design & Web Development

Demo

Sponsored links

 

Code

HTML

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Layered Image Hover Effects</title>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <div id="container">
      <div class="layered-image">
        <div class="image">
          <img src="square.png">
          <img src="square.png">
          <img src="square.png">
          <img src="square.png">
        </div>
      </div>
      <h1>Layered<br>Image<br>Hover<br>Effects</h1>
    </div>
  </body>
</html>

CSS

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400&display=swap');
body {
  margin: 0;
  padding: 0;
  font-family: 'Roboto', sans-serif;
}
h1 {
  font-size: 48px;
  color: #faeac2;
}
#container {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url(bg.png);
  background-size: cover;
}
.layered-image {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 220px;
  padding-left: 60px;
  margin-right: 70px;
}
.image {
  width: 150px;
  height: 150px;
  background: rgba(239, 175, 53, .1);
  transform: rotate(-30deg) skew(25deg);
  transition: .5s;
}
.image img {
  position: absolute;
  width: 100%;
  transition: .5s;
}
.image:hover img:nth-child(1) {
  transform: translate(40px, -40px);
  opacity: .2;
}
.image:hover img:nth-child(2) {
  transform: translate(80px, -80px);
  opacity: .4;
}
.image:hover img:nth-child(3) {
  transform: translate(120px, -120px);
  opacity: .7;
}
.image:hover img:nth-child(4) {
  transform: translate(160px, -160px);
  opacity: 1;
}
@media screen and (max-width: 480px) {
  h1 {
    font-size: 24px;
  }
  .image {
    width: 80px;
    height: 80px;
  }
  .layered-image {
     padding-top: 100px;
     padding-left: 30px;
     margin-right: 50px;
  }
  .image:hover img:nth-child(1) {
    transform: translate(20px, -20px);
    opacity: .2;
  }
  .image:hover img:nth-child(2) {
    transform: translate(40px, -40px);
    opacity: .4;
  }
  .image:hover img:nth-child(3) {
    transform: translate(60px, -60px);
    opacity: .7;
  }
  .image:hover img:nth-child(4) {
    transform: translate(80px, -80px);
    opacity: 1;
  }
}