Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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="banner" class="banner">
  <div class="container">
    <div id="bg-color" class="bg-color"></div>
    <div id="stage" class="stage"></div>
  </div>
<div class="border"></div>
</div>
              
            
!

CSS

              
                img {
	max-width: auto;
	max-height: 100%;
}
#banner, body {margin: 0; padding: 0;} #banner,
img {position: absolute; left: 0; top: 0; width: 300px; height: 250px; opacity: 1;}
.img-bg {position: absolute; left: 0; top: 0; width: 300px; height: 250px; opacity: 1;}

#banner {
	background: #FFF;
	cursor: pointer;
	-webkit-transform: translate3d(0, 0, 0);
	transform: translate3d(0, 0, 0);
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}
#banner,
.border,
.container {
	width: 300px;
	height: 250px;
}
.border,
.container {
	position: absolute;
	left: 0;
	top: 0;
}
#banner,
.container {
	overflow: hidden;
}
.border {
	border: 1px solid rgba(0,0,0,0.5);
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	z-index: 9999;
  }
#bg-color {
	z-index: 10;
	position: absolute;
	left: 0;
	top: 0;
	width: 300px;
	height: 0px;
	opacity: 0;
	background-color: #000000; 
}
#stage {
	z-index: 1;
	position: absolute;
	left: 0;
	top: 0;
	width: 300px;
	height: 250px;
	opacity: 1;
	background-color: #ffffff; 
}
              
            
!

JS

              
                'use strict';
console.clear();
var toggle = 0;
function _classCallCheck(t, e) {
  if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
}

// create main timeline
var masterTl = new TimelineMax({paused:true, onComplete:onComplete});

// create a function returning first timeline
function firstTl() {
  var tl = new TimelineMax()
  	
  return tl;
}

// create a function returning second timeline
function secondTl() {
  var tl = new TimelineMax()
  	.fromTo("#bg-color", 1, {height: 0, autoAlpha: 0}, {height: 135, autoAlpha: 1}, "+=0.0")
  return tl;
}


// make this all happen on page load
function init(){
// add sub timeline to main timeline
masterTl
.add(firstTl(), "+=0.0")
.add(secondTl(), "+=5")
.play();
}

// Test play reverse

// This function will return one element
var select = document.querySelector.bind(document);

// This function will return a node-list of elements
// It's not used in this example, but I included it in case
// you were wondering how to select more than one element
var selectAll = document.querySelectorAll.bind(document);

// Select our elements
var banner = select("#banner");
var bgcolor = select("#bg-color");

// Create a paused timeline with our tweens
var tl = new TimelineLite({ paused: true })
  .to(bgcolor, 0.2, { width: 300, height: 250, autoAlpha: 1 });

TweenLite.set(banner, {visibility:"visible"})

TweenLite.from(bgcolor, .7, {
	autoAlpha: 0,
});



function onComplete() {
  if(document.querySelector("#banner:hover")) { tl.play();}
  banner.addEventListener("mouseenter", function() {tl.play();} );    
  banner.addEventListener("mouseleave", function() {tl.reverse();} );
}


window.onload = init;
              
            
!
999px

Console