【CSS】画像の上で光沢のある演出を交えて単色の要素がスライドするカーテンアニメーションの実装方法のデモページ/Curtain animation in which a glossy single color element slides on the image(Demo page)

※デベロッパーツール等でソースコードをご確認ください

スポンサーリンク

CSS

.block {
  position: relative;
  display: block;
  width: 768px;
  line-height: 0;
  overflow: hidden;
  margin: 50px auto 0;
}

.block img {
  width: 100%;
  transition: 0.8s cubic-bezier(0.82, 0.01, 0.28, 0.99) 0.4s;
  opacity: 0;
}

.active.block img {
  opacity: 1;
}

.block:before {
  content: ' ';
  display: block;
  position: absolute;
  top: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  opacity: 1;
  background: #55310e;
  transition: 0.8s cubic-bezier(0.82, 0.01, 0.28, 0.99);
  transform: translateX(0%) skewX(0deg);
}

.active.block:before {
  opacity: 0;
  transform: translateX(100%) skewX(-20deg);
}

.block:after {
  content: ' ';
  display: block;
  position: absolute;
  top: 0;
  z-index: 2;
  width: 40%;
  height: 100%;
  opacity: 1;
  background: #fff;
  transition: 1s cubic-bezier(0.82, 0.01, 0.28, 0.99) 0.3s;
  transform: translateX(-120%) skewX(-10deg);
}

.active.block:after {
  opacity: 0;
  transform: translateX(180%) skewX(-30deg);
}

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

JavaScript

$(window).on('load', function(){
    $(".block").addClass("active");
  });