【CSS】How to implement animation that overlays two colors on the image and moves them up and down | Demo page

※Please check using Developer tools

Sponsored links

CSS

.block {
  width: 768px;
  overflow: hidden;
  margin: 50px auto 0;
}

.box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
}

.left,.right {
  position: absolute;
  top: 0;
  display: block;
  width: 50%;
  height: 100%;
  transition: transform 1s cubic-bezier(0.2, 1.1, 0.4, 1);
}

.left {
  left: 0;
  background: #000;
  transform: translate3d(0, 100%, 0);
}

.right {
  right: 0;
  background: #ddd;
  transform: translate3d(0, -100%, 0);
}

.active .left,.active .right {
  transform: translate3d(0, 0, 0);
  animation: anime 3s ease both;
}

.img {
  transition: all 1.5s 1s;
  opacity: 0;
}

.active .img {
  opacity: 1;
}

@keyframes anime {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@media screen and (max-width:640px){
  .block {
    width: 100%;
  }
}
  

JavaScript

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