<section id="tilt">
    <div class="text">
      <h2>Hover on the image</h2>
      <p>It uses a combination of all the rotate operators</p>
      <div class="tilt-img">
        <img src="https://omjsblog.wordpress.com/wp-content/uploads/2024/06/7.jpg" alt="">
      </div>
    </div>
  </section>
@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}
body {
  width: 100%;
  height: 100vh;
  background: radial-gradient(#480d35, #17151d);
}
.text {
  text-align: center;
  margin: 5px;
}
.text h2 {
  font-size: 2rem;
  font-weight: 500;
  color: #f6d8d5;
}
.text p {
  font-size: 1.5rem;
  color: #b393d3;
}
#tilt {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 30px 10px;
  flex-direction: column;
}
.tilt-img {
  width: 600px;
  height: auto;
  margin-top: 20px;
  perspective: 1000px;
}
.tilt-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  transform: rotateX(15deg) rotateY(-5deg) rotateZ(1deg);
  box-shadow: 5px 5px 2px rgba(0, 0, 0, 0.5);
  transition: 2s;
}
.tilt-img:hover img{
  transform: none;
  box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.5);
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.