【CSS】How to implement a curtain animation in which the color superimposed on the image slides while giving a glossy feeling | デモページDemo page

※Please check using Developer tools

Sponsored links

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");
});