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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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 class="figure">
    <video id="bgvid" playsinline muted loop>
  		<!-- SET ALL 3 SOURCES TO ENSURE VISIBILITY -->
        <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4" />
        <source src="https://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg" />
	</video>
  	<!-- FRAME 1 CONTENT -->
    <div class="frame1">
      <h1 id="frame1header" class="header">HI! :)</h1>
    </div>
    
    <!-- FRAME 2 CONTENT -->
    <div class="frame2">
      <h1 id="frame2header" class="header">NOOOoooo!...</h1>
    </div>
    
    <!-- FRAME 3 CONTENT -->
    <div class="frame3">
      <h1 id="frame3header" class="header">Finished</h1>
    </div>
</div>


              
            
!

CSS

              
                body {
  font-family: arial;
  background: #fff;
  margin:0px;
  padding:0px;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  height: 100vh;
  -webkit-box-align: center;
  -webkit-align-items: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.figure {
  position: relative;
  width: 300px; /* DEFINE WIDTH OF BANNER HERE */
  height: 250px; /* DEFINE HEIGHT OF BANNER HERE */
  border: 1px solid rgba(0, 0, 0, .8);
  box-sizing: border-box;
	-moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
  overflow: hidden;
}

.frame1, .frame2, .frame3, .frame4 {
    opacity:0;
	width: 300px; /* DEFINE WIDTH OF BANNER HERE */
    height: 250px; /* DEFINE HEIGHT OF BANNER HERE */
    position: absolute;
}


video { 
    position:absolute;
	background: #fff;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
	transform: translateX(-50%) translateY(-50%);
  	transition: 1s opacity;
	opacity:0;
}

#pauseButton {
    position: absolute;
	border:hidden;
    top: 3px;
    width: 20px;
    height: 20px;
    right: 3px;
	z-index: 1000;
	opacity:.5;
	cursor:pointer;
	display:none;
}

h1 {padding:20px;}
              
            
!

JS

              
                var vid = document.getElementById("bgvid");
var runanimation = true;
var loopnr = 0;

var tl = new TimelineMax({delay:0, repeat:3, repeatDelay:0, onRepeat:everyLoop, onComplete:showfinalframe});
	tl.
	from(['#bgvid'], 0, {delay:0, opacity:0})
	.to(['#bgvid'], 0, {delay:.1, opacity:1})
	.to(['.frame1'], .2, {delay:.2, opacity:1})
	.to(['.frame1'], .2, {delay:6.3, opacity:0})
	.to(['.frame2'], .2, {delay:.2, opacity:1})
	.to(['.frame2'], .2, {delay:.8, opacity:0})
	.from(['#bgvid'], .2, {delay:0, opacity:1})
	.to(['#bgvid'], .2, {delay:.1, opacity:0})

	tl.pause();// pause timeline until video is playing
	vid.play();// Start video

	
	// Function for when video is playing which will start timeline and show pause button
	vid.addEventListener("playing", function () {
  		if(vid.readyState >= 3 && runanimation == true) {
			  tl.play();
			  console.log("Video and text animations are running");
			  runanimation = false;// so this IF statement is not trickered again
      }
	});
 
  
 // ---- The final/fallback frame - START ----------------------------------------------------------------------------
function showfinalframe() {
	TweenMax.to(['.frame3'], .5, {delay:0, opacity:1})
	TweenMax.from('.frame3', 1, {delay:.5, x:0, ease:Power2.easeOut})
	vid.pause();
}


// ---- On timeline repeat function -------------------------------------------------------------------------	
function everyLoop() {
  loopnr++
	vid.currentTime = 0.0; // Restarts the video on every timeline repeat
  console.log("LOOP" + loopnr);
}
              
            
!
999px

Console