Pure CSS Tilt Image Animation

Web Design & Web Development

Demo

Sponsored links

 

Code

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Tilt Image Animation</title>
    <link rel="stylesheet" type="text/css" href="https://demo.plantpot.works/assets/css/normalize.css">
    <link rel="stylesheet" href="https://use.typekit.net/opg3wle.css">
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <div id="container">
      <div class="box">
        <div class="image"></div>
        <div class="shadow"></div>
        <h1>Tilt Image Animation</h1>
      </div>
    </div>
  </body>
</html>

CSS

@charset "utf-8";
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
}
body {
  background-color: #005ebb;
  font-family: futura-pt, sans-serif;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
}
.box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 720px;
  height: 100vw;
  max-height: 720px;
  padding: 20px 0;
}
.box h1 {
  margin: 30px 0 0;
  color: #fff;
  font-weight: 600;
  font-size: 3rem;
  letter-spacing: 1px;
  text-align: center;
}
.image {
  position: relative;
  width: 200px;
  height: 200px;
  overflow: hidden;
  background-image: radial-gradient(circle at 120px 0, #D0F800, #49EA10);
  animation: tiltImage 2s linear infinite;
}
.image::before {
  opacity: .4;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transform: skewX(-20deg);
  background-color: #fff;
  content: '';
  animation: gloss 2s linear infinite;
}
.shadow {
  width: 200px;
  height: 8px;
  margin-top: 50px;
  border-radius: 50%;
  background-color: #000;
  filter: blur(10px);
  animation: tiltImage 2s linear infinite;
}
@keyframes tiltImage {
  0% {
    transform: skewY(5deg);
  }
  50% {
    transform: skewY(-5deg);
  }
  100% {
    transform: skewY(5deg);
  }
}
@keyframes gloss {
  0% {
    transform: translateX(-120px) skewX(-20deg);
  }
  50% {
    transform: translateX(-80px) skewX(-20deg);
  }
  100% {
    transform: translateX(-120px) skewX(-20deg);
  }
}
@media screen and (max-width: 480px) {
  #container {
    height: auto;
    align-items: flex-start;
  }
  .box {
    height: 400px;
  }
  .box h1 {
    font-size: 1.5rem;
  }
}