Home > database >  How to end loading animation and switch to another slide HTML CSS
How to end loading animation and switch to another slide HTML CSS

Time:08-29

Here is CSS

@import url(https://fonts.googleapis.com/css?family=Quattrocento Sans);

@import url(https://fonts.googleapis.com/css?family=Quattrocento Sans);
.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  z-index: 9999;
}
.loading-img-img {
    top: 15%;
    position: relative;
}   
.loading-img {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  text-align: center;
  width: 100%;
  height: 100px;
  line-height: 100px;
}
.loading-img span {
  display: inline-block;
  margin: 0 5px;
  font-family: "Quattrocento Sans", sans-serif;
  font-size: 30px;
}
.loading-img span:nth-child(1) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0s infinite linear alternate;
          animation: blur-img 1.5s 0s infinite linear alternate;
}
.loading-img span:nth-child(2) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0.2s infinite linear alternate;
          animation: blur-img 1.5s 0.2s infinite linear alternate;
}
.loading-img span:nth-child(3) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0.4s infinite linear alternate;
          animation: blur-img 1.5s 0.4s infinite linear alternate;
}
.loading-img span:nth-child(4) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0.6s infinite linear alternate;
          animation: blur-img 1.5s 0.6s infinite linear alternate;
}
.loading-img span:nth-child(5) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0.8s infinite linear alternate;
          animation: blur-img 1.5s 0.8s infinite linear alternate;
}
.loading-img span:nth-child(6) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 1s infinite linear alternate;
          animation: blur-img 1.5s 1s infinite linear alternate;
}
.loading-img span:nth-child(7) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 1.2s infinite linear alternate;
          animation: blur-img 1.5s 1.2s infinite linear alternate;
}
.loading-img span:nth-child(8) {
    filter: blur(0px);
    -webkit-animation: blur-img 1.5s 1.4s infinite linear alternate;
            animation: blur-img 1.5s 1.4s infinite linear alternate;
  }
  .loading-img span:nth-child(9) {
    filter: blur(0px);
    -webkit-animation: blur-img 1.5s 1.6s infinite linear alternate;
            animation: blur-img 1.5s 1.6s infinite linear alternate;
  }
  .loading-img span:nth-child(10) {
    filter: blur(0px);
    -webkit-animation: blur-img 1.5s 1.8s infinite linear alternate;
            animation: blur-img 1.5s 1.8s infinite linear alternate;
  }
@-webkit-keyframes blur-img {
  0% {
    filter: blur(0px);
  }
  100% {
    filter: blur(4px);
  }
}

@keyframes blur-img {
  0% {
    filter: blur(0px);
  }
  100% {
    filter: blur(4px);
  }
}
<div >
        <div >
          <span >
              <img src="images/logo.png" height="50px" width="50px">
          </span>
          <span >G</span>
          <span >R</span>
          <span >A</span>
          <span >V</span>
          <span >G</span>
          <span >I</span>
          <span >F</span>
          <span >T</span>
        </div>
      </div>

CodePudding user response:

For example, the loading can be hidden once its purpose is fulfilled, with the following:

window.onload = function() {
  setTimeout(function() {
    document.querySelector(".loading").style.display = 'none';
  }, 6000);
};
@import url(https://fonts.googleapis.com/css?family=Quattrocento Sans);
.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  z-index: 9999;
}

.loading-img-img {
  top: 15%;
  position: relative;
}

.loading-img {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  text-align: center;
  width: 100%;
  height: 100px;
  line-height: 100px;
}

.loading-img span {
  display: inline-block;
  margin: 0 5px;
  font-family: "Quattrocento Sans", sans-serif;
  font-size: 30px;
}

.loading-img span:nth-child(1) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0s infinite linear alternate;
  animation: blur-img 1.5s 0s infinite linear alternate;
}

.loading-img span:nth-child(2) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0.2s infinite linear alternate;
  animation: blur-img 1.5s 0.2s infinite linear alternate;
}

.loading-img span:nth-child(3) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0.4s infinite linear alternate;
  animation: blur-img 1.5s 0.4s infinite linear alternate;
}

.loading-img span:nth-child(4) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0.6s infinite linear alternate;
  animation: blur-img 1.5s 0.6s infinite linear alternate;
}

.loading-img span:nth-child(5) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 0.8s infinite linear alternate;
  animation: blur-img 1.5s 0.8s infinite linear alternate;
}

.loading-img span:nth-child(6) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 1s infinite linear alternate;
  animation: blur-img 1.5s 1s infinite linear alternate;
}

.loading-img span:nth-child(7) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 1.2s infinite linear alternate;
  animation: blur-img 1.5s 1.2s infinite linear alternate;
}

.loading-img span:nth-child(8) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 1.4s infinite linear alternate;
  animation: blur-img 1.5s 1.4s infinite linear alternate;
}

.loading-img span:nth-child(9) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 1.6s infinite linear alternate;
  animation: blur-img 1.5s 1.6s infinite linear alternate;
}

.loading-img span:nth-child(10) {
  filter: blur(0px);
  -webkit-animation: blur-img 1.5s 1.8s infinite linear alternate;
  animation: blur-img 1.5s 1.8s infinite linear alternate;
}

@-webkit-keyframes blur-img {
  0% {
    filter: blur(0px);
  }
  100% {
    filter: blur(4px);
  }
}

@keyframes blur-img {
  0% {
    filter: blur(0px);
  }
  100% {
    filter: blur(4px);
  }
}
<div >
  <div >
    <span >
              <img src="images/logo.png" height="50px" width="50px">
          </span>
    <span >G</span>
    <span >R</span>
    <span >A</span>
    <span >V</span>
    <span >G</span>
    <span >I</span>
    <span >F</span>
    <span >T</span>
  </div>
</div>
<div>Content reveal after page entirely loaded</div>

The setTimeout is for showing the loader even if the site content is already on the client side.

  • Related