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

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

<div id="main" class="main-container">
    <article id="slide01" class="slide">
        <div class="bcg"></div>
        <div class="wrapper">
            <h1>Damage report! Talk about going nowhere fast.</h1>
            <p>I recommend you don't fire until you're within 40,000 kilometers. Commander William Riker of the Starship Enterprise. Some days you get the bear, and some days the bear gets you.</p>
        </div> <!-- .wrapper -->
    </article>
    <article id="slide02" class="slide">
        <div class="bcg"></div>
        <div class="wrapper">
            <h1>Mr. Worf, you do remember how to fire phasers?</h1>
            <p>The unexpected is our normal routine. Earl Grey tea, watercress sandwiches... and Bularian canapés? Are you up for promotion? Fate protects fools, little children and ships named Enterprise..</p>
        </div> <!-- .wrapper -->
    </article>
    <article id="slide03" class="slide">
        <div class="bcg"></div>
        <div class="wrapper">
            <h1>Smooth as an android's bottom, eh, Data?</h1>
            <p>Well, that's certainly good to know. Now, how the hell do we defeat an enemy that knows us better than we know ourselves? I think you've let your personal feelings cloud your judgement.</p>
        </div> <!-- .wrapper -->
    </article>
</div> <!-- #main-container -->
              
            
!

CSS

              
                * {
  margin:0;
  padding:0; 
}
html, body {
  height: 100%;
  margin: 0; 
}
body {
  font: 16px/1.5 'Raleway', Helvetica, Helvetica Neue, Arial, sans-serif;
  background-color: #212121; 
}
p {
  font-size: 16px; 
}

/* =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; 
}
.slide {
  color: #ffffff;
  height: 100vh;
  position: relative; 
}
.slide .wrapper {
  text-align: center;
  position: relative;
  top:50%;
  transform:translateY(-50%);
  z-index: 2; 
  width: 80%;
  margin: 0 10%;   
}
.bcg {
  background: no-repeat center center;
  background-size: cover;
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1; 
  opacity:.5;
}
#slide01 .bcg {
  background: url('http://3.bp.blogspot.com/-rq_9ryXjXyw/VdqECM5u4OI/AAAAAAAAPyk/4TEqMx7oOK8/s1600/USS+enterprise+NCC+1701-D.JPG') no-repeat center center;
  background-size: cover; 
}
#slide02 .bcg {
  background: url('https://clarkkent81.files.wordpress.com/2012/07/star-trek-horizontal.jpg') no-repeat center center;
  background-size: cover; 
}
#slide03 .bcg {
  background: url('http://tng.trekcore.com/hd/albums/1x23/skinofevil_hd_495.jpg') no-repeat center center;
  background-size: cover; 
}
              
            
!

JS

              
                	// load images
	var loadedCount = 0; //current number of images
	var imagesToLoad = $('.bcg').length; //number of slides with .bcg 
	var loadingProgress = 0; //timeline progress - starts at 0

	$('.bcg').imagesLoaded({
	    background: true
	  }
	).progress( function( instance, image ) { 
		loadProgress();
	});

	TweenLite.from('.txt-perc', 0.7, {autoAlpha:0, y: '-150px'});

	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});

	}

	//progress animation
	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 + '%');

	}


// 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('html', {className: '-=is-loading'})
  .set('#slide01', {className: '+=is-loaded'})
  .to('#preloader', 0.7, {yPercent: 100, ease:Power4.easeInOut})
  .set('#preloader', {className: '+=is-hidden'})
  .from('#slide01 h1', 1, {autoAlpha: 0, ease:Power1.easeOut}, '-=0.2')
  .from('#slide01 p', 0.7, {autoAlpha: 0, ease:Power1.easeOut}, '+=0.2');

//force the playhead to jump to the end in order to pre-render all the tweens, then back to the start and pause.
preloaderOutTl.progress(1).pause(0);

function loadComplete() {
  preloaderOutTl.play();
}
              
            
!
999px

Console