Preloader

by sazakharov

HTML

<body class="apus-body-loading">
<div class="apus-page-loading" style="">
	  	<div id="loader"></div>
	  	<div class="loader-section section-left"></div>
	  	<div class="loader-section section-right"></div>
</div>
<div id="wrapper-container" class="wrapper-container">
  SOME CONTENT...
</div>
</body>

CSS

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
@keyframes -webkit-spin {
  0% {
    -webkit-transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
  }
}

.apus-page-loading {
  height: 100%;
  left: 0;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 99991;
}

/* outer arc */
.apus-page-loading #loader {
  animation: 2s linear 0s normal none infinite running spin;
  -webkit-animation: 2s linear 0s normal none infinite running spin;
  -ms-animation: 2s linear 0s normal none infinite running spin;
  border-color: blue transparent transparent;
  border-image: none;
  border-radius: 50%;
  border-style: solid;
  border-width: 3px;
  display: block;
  height: 100px;
  left: 50%;
  margin-left: -75px;
  margin-top: -75px;
  position: relative;
  top: 50%;
  width: 100px;
  z-index: 1001;
}

/* second arc */
.apus-page-loading #loader:before {
  animation: 3s linear 0s normal none infinite running spin;
  -webkit-animation: 3s linear 0s normal none infinite running spin;
  -ms-animation: 3s linear 0s normal none infinite running spin;
  border-color: green transparent transparent;
  border-image: none;
  border-radius: 50%;
  border-style: solid;
  border-width: 3px;
  bottom: 5px;
  content: "";
  left: 5px;
  position: absolute;
  right: 5px;
  top: 5px;
}

/* inner arc */
.apus-page-loading #loader:after {
  animation: 1.5s linear 0s normal none infinite running spin;
  -webkit-animation: 1.5s linear 0s normal none infinite running spin;
  -ms-animation: 1.5s linear 0s normal none infinite running spin;
  border-color: red transparent transparent;
  border-image: none;
  border-radius: 50%;
  border-style: solid;
  border-width: 3px;
  bottom: 15px;
  content: "";
  left: 15px;
  position: absolute;
  right: 15px;
  top: 15px;
}

/* Backgorund */
.apus-page-loading .loader-section {
  background: #c0c0f5 none repeat scroll 0 0;
  height: 100%;
  position: fixed;
  top: 0;
 ...

JavaScript

jQuery(document).ready(function() {
        // preload page
        var $body = $('body');
        if ( $body.hasClass('apus-body-loading') ) {

            setTimeout(function() {
                $body.removeClass('apus-body-loading');
                $('.apus-page-loading').fadeOut(250);
            }, 400);
        }
});