【CSS】ホバー時に画像を斜めに傾けて立体的に表現するテクニックのデモページ/To obliquely tilt the image when hover to express it three-dimensionally(Demo page)

※デベロッパーツール等でソースコードをご確認ください(Please check using Developer tools)

スポンサーリンク

CSS

.block {
  width: 300px;
  margin: 0 auto;
}

.block a {
  display: block;
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.block a .box {
  position: relative;
  padding-top: 62.5%;
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.block a .box:after {
  content: '';
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  transform: translateX(0) translateY(0);
  background: #000;
}

.block a .img {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: url(/img/a.jpg) no-repeat center center;
  background-size: cover;
}

.block a:hover {
  perspective: 1000px;
}
.block a:hover .box {
  transform: rotateX(30deg) rotateY(-20deg) rotateZ(5deg);
}

.block a:hover .box:after {
  transform: translateX(20px) translateY(20px);
}

@media screen and (max-width:640px){
  .block {
    width: 100%;
  }
}