【CSS】A method to implement an opening animation that moves the color on the entire screen at the time of page access to diagonally upward right and diagonally downward left(Demo page)

※Please check using Developer tools

スポンサーリンク

CSS

body {
  background: #000;
}

.wrap {
  height: 2000px;
}

.color {
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100%;
}

.block {
  position: absolute;
  z-index: -1;
  top: 0;
  width: 0;
  height: 100%;
  transition: transform 1.5s .7s cubic-bezier(0,.7,.5,1);
}

.block.left {
  left: 0;
}

.block.right {
  right:0;
}

.block.left:after,
.block.right:after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-color: transparent;
}

.block.left:after {
  left: 0;
  bottom: 0;
  border-width: 100vw 0 0 100vw;
  border-left-color: #fff;
}

.block.right:after {
  right: 0;
  top: 0;
  border-width: 0 100vw 100vw 0;
  border-right-color: #fff;
}

.show .block.left {
  transform:translateX(-100vw);
}

.show .block.right {
  transform:translateX(100vw);
}
@media screen and (max-width:640px){
  .color {
    display: none;
  }
}
  

JavaScript

$(function(){
  $('body').addClass('show');
   setTimeout(function(){
     $(".color").remove();
   },2000);
});