Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
    <body class="is-loading">

        <div id="preloader">
            <div class="txt">
                <p class="txt-perc">0%</p>
                <div class="progress"><span></span></div>
            </div>
        </div>

        <div id="intro" class="header-container fs">
          <div class="bcg"></div>
 
        </div>


    </body> 
              
            
!

CSS

              
                 
body {
  background-color: #212121;
}
html,
body {
  height: 100%;
  margin: 0;
}
 
/* =Preloader */

#preloader {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 101;
  background-color: #212121;
  color: #ffffff;
}

#preloader .txt {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

#preloader .txt-perc {
  font-size: 35px;
  font-family: 'Roboto Condensed', Helvetica, Helvetica Neue, Arial, sans-serif;
  opacity: 1;
  margin: 0 0 6px 0;
  max-width: 400px;
  text-align: center;
}

#preloader .progress {
  width: 100px;
  height: 3px;
  background-color: rgba(255, 255, 255, 0.2);
  margin: 0 auto 15px auto;
}

#preloader .progress span {
  display: block;
  width: 0;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
}

#preloader.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.is-loading {
  overflow: hidden;
}
 

.bcg {
  background-image: url(https://ihatetomatoes.net/demos/scrollmagic-templates/scrollmagic-template-04/img/img_mountains01.jpg);
  background-repeat:no-repeat;
  background-position: center center;
  background-size: cover;
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 1;
} 
              
            
!

JS

              
                (function($) { 
  // number of loaded images for preloader progress 
  var loadedCount = 0; //current number of images loaded
  var imagesToLoad = $('.bcg').length; //number of slides with .bcg container
  var loadingProgress = 0; //timeline progress - starts at 0
  
  $('.bcg').imagesLoaded({
    background: true
  }).progress(function(instance, image) {
    loadProgress();
  });

  function loadProgress(imgLoad, image) {
    //one more image has been loaded
    loadedCount++;

    loadingProgress = (loadedCount / imagesToLoad);
 
    // GSAP timeline for our progress bar
    TweenLite.to(progressTl, 0.7, {
      progress: loadingProgress,
      ease: Linear.easeNone
    });

  }
  
 
  var progressTl = new TimelineMax({
    paused: true,
    onUpdate: progressUpdate,
    onComplete: loadComplete
  });

  progressTl
  //tween the progress bar width
    .to($('.progress span'), 1, {
    width: 100,
    ease: Linear.easeNone
  });

  //as the progress bar witdh updates and grows we put the precentage loaded in the screen
  function progressUpdate() {
    //the percentage loaded based on the tween's progress
    loadingProgress = Math.round(progressTl.progress() * 100);
    //we put the percentage in the screen
    $(".txt-perc").text(loadingProgress + '%');

  }

  function loadComplete() {

    // preloader out
    var preloaderOutTl = new TimelineMax();

    preloaderOutTl
      .to($('.progress'), 0.3, {
        y: 100,
        autoAlpha: 0,
        ease: Back.easeIn
      })
      .to($('.txt-perc'), 0.3, {
        y: 100,
        autoAlpha: 0,
        ease: Back.easeIn
      }, 0.1)
      .set($('body'), {
        className: '-=is-loading'
      })
      .set($('#intro'), {
        className: '+=is-loaded'
      })
      .to($('#preloader'), 0.7, {
        yPercent: 100,
        ease: Power4.easeInOut
      })
      .set($('#preloader'), {
        className: '+=is-hidden'
      });

    return preloaderOutTl;
  }
   
    var introTl = new TimelineMax();

    introTl  
      .to($('#intro'), 0.7, {
        autoAlpha: 0.5,
        ease: Power1.easeNone
      }, 0); 
  
  
}(jQuery));
              
            
!
999px

Console