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>


	<div class="container center">
	
		<div id="titel" class="center">New Books</div>
		
		<div class="partBlue">
		  <div id="HeadBlue" class="center">BLUE</div>
		  <div id="blueButton" class="blue center">more</div>
		  <div class="page pageBlue">
				<p class="head02 center">more Copy</p>
		  </div>	  
		</div>

		<div class="partGreen">
			<div class="HeadGreen center">GREEN</div>
			<div id="greenButton" class="green center">more</div>
		  <div class="page pageGreen">
				<p class="head02 center">more Copy</p>
		  </div>
		</div>
		
  </div>
	<a id="backBlue" class="backBlue" title="zurück zur HOME">Home</a>
	<a id="backGreen" class="backGreen" title="zurück zur HOME">Home</a>
  </body>
              
            
!

CSS

              
                body {
  width: 100%;
  height: 100%;
  margin: 0;
  color: white;
  font-size: 50px;
  text-align: center;
  overflow: hidden;
}

.center {
	position: relative;
	top: 50%;
	left: 50%;
}

.container {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 88%;
  z-index: -1;
  background-color: white;
  visibility: hidden;
  opacity: 0;
}
#titel {
	position: absolute;
    z-index: 10;
    top: 20%;
    padding: 5px 32px;
    background: white;
    color: black;
	visibility: hidden;
}
.page {
	position: absolute;
	top: 0;
	width: 300%;
	height: 100%;
	font-size: 1.4em;
	z-index: 0;
}
/* ===== BLUE PART ===========*/
.partBlue {
  position: absolute;
  height: 100%;
  width: 50%;
  left: 0%;
  z-index: 2;
  background: blue;
  float: left;
}

#HeadBlue {
  position: relative;
}

#blueButton, #greenButton {
  position: relative;
  cursor: pointer;
  font-size: 26px;
}

.backBlue {
    position: fixed;
    top: auto;
    bottom: 12px;
    left: 86%;
    width: 50px;
    font-size: 18px;
    line-height: 12px;
    color: black;
    cursor: pointer;
	opacity: 0;
	visibility: hidden;
}
.pageBlue {
	left: -300%;
	background: rgb(30, 33, 125);
}
/* ===== GREEN PART ===========*/
.partGreen{
	position: absolute;
    width: 50%;
    height: 100%;
    left: 50%;
	z-index:1;
	background: green;
    display: block;
	z-index: 1;
}
.pageGreen {
	left: 100%;
	background: #1C461C;
}
.backGreen {
	position: fixed;
    top: auto;
    bottom: 12px;
    left: 11%;
    width: 50px;
    font-size: 18px;
    line-height: 12px;
    color: black;
    cursor: pointer;
	visibility: hidden;
}


@media (max-width: 480px) {
.partBlue {
    font-size: 26px;
    height: 50%;
    width: 100%;
}
.partGreen {
	top: 50%;
	left: 0%;
    font-size: 26px;
    height: 50%;
    width: 100%;
}
#titel {
    top: 50%;
    padding: 5px 28px;
    font-size: 18px;
}
#blueButton, #greenButton {
    font-size: 18px;
}

}
              
            
!

JS

              
                
window.onload = function() {

  TweenLite.set(".center", { xPercent: -50, yPercent: -50 });
  TweenLite.set(".container, #titel", { autoAlpha: 1 });

// ==== PartAnimations ====================================  
  // Keep track of timeline reversed state
  //var reversed = true;
	var blueReversed = true;
	var greenReversed = true;
  
  var BLUE = new TimelineLite();
  var GREEN = new TimelineLite();

  // Add a media query
  var mediaQuery = window.matchMedia("(max-width:480px)");
	
  // Add a listener 
	mediaQuery.addListener(setAnimationBLUE);
	mediaQuery.addListener(setAnimationGREEN);
	
	// Run the query to setup the initial animation
	setAnimationBLUE(mediaQuery);
	setAnimationGREEN(mediaQuery);

// ==== Part BLUE ====================================  
  $("#blueButton, #backBlue").click(animateBLUE);

  function animateBLUE() {
    
    // Timeline is setup so that all you need to do is reverse it
    /*reversed = !reversed;
    BLUE.reversed(reversed);*/
		
		blueReversed = !blueReversed;
    BLUE.reversed(blueReversed);
  }
  
  function setAnimationBLUE(mediaQuery) {
    
    var progress = BLUE.progress() || 0;
		var PartBlue, pageBlue, backBLUE, HeadBlue;
    
    // Matches if width is < 481px
    if (mediaQuery.matches) {      
      PartBlue = { height: "100%" }
			pageBlue = { left: "0%", height: "100%", width: "100%" }
			backBLUE = { left: "44%", autoAlpha: 1 }
			HeadBlue = {rotation: -90, scale: 0.8, immediateRender:false}

    } else {
			PartBlue = { left: "75%", width: "25%"  }
			pageBlue = { left: "-300%", height: "100%", width: "300%" }
			backBLUE = { left: "87%", autoAlpha: 1 }
			HeadBlue = {rotation: -90, scale: 0.8, immediateRender:false}	 
	}
    
    // Clear the timeline
    BLUE.seek(0).clear();
	
    
    // Clear props
    TweenMax.set(".partBlue", { clearProps: "all" });
    
    // Build timeline
    BLUE.to("#titel", 0.5, {autoAlpha: 0})
		.to("#blueButton", 0.5, {autoAlpha: 0})
		.to(".partBlue", 1, PartBlue)
		.to(".pageBlue", 1, pageBlue, "-=1")
		.to("#HeadBlue", 1, HeadBlue, "-=1")
		.to("#backBlue", 0.1, backBLUE, "-=1.5")
		//.reversed(reversed)
		.reversed(blueReversed)
		.progress(progress);
  }

  // ==== Part GREEN ====================================
	
  $("#greenButton, #backGreen").click(animateGREEN);
  
  function animateGREEN() {
    
    // Timeline is setup so that all you need to do is reverse it
    /*reversed = !reversed;
    GREEN.reversed(reversed);*/
		
		greenReversed = !greenReversed;
    GREEN.reversed(greenReversed);
  }
  
  function setAnimationGREEN(mediaQuery) {
    
    var progress = GREEN.progress() || 0;
		var PartGreen, pageGreen, backGREEN, HeadGreen;
    
    // Matches if width is < 481px
    if (mediaQuery.matches) {      
			PartGreen = { top: "0%", height: "100%" }
			pageGreen = { left: "0%", height: "100%", width: "100%" }
			backGREEN = { left: "44%", autoAlpha: 1 }
			HeadGreen = {rotation: -90, scale: 0.8, immediateRender:false}

    } else {
      PartGreen = { left: "0%", width: "25%"  }
			pageGreen = { height: "100%", width: "300%" }
			backGREEN = { left: "11%", autoAlpha: 1 }
			HeadGreen = {rotation: -90, scale: 0.8, immediateRender:false}
    }
    
    // Clear the timeline
    GREEN.seek(0).clear();
	
    // Clear props
    TweenMax.set(".partGreen", { clearProps: "all" });
    
    // Build timeline
    GREEN.to("#titel", 0.5, {autoAlpha: 0})
		.set(".partGreen", {zIndex: 2})
		.to("#greenButton", 0.5, {autoAlpha: 0})
		.to(".partGreen", 1, PartGreen)
		.to(".pageGreen", 1, pageGreen, "-=1")
		.to(".HeadGreen", 1, HeadGreen, "-=1")
		.to("#backGreen", 0.1, backGREEN, "-=1.5")
		//.reversed(reversed)
		.reversed(greenReversed)
		.progress(progress);
  }    
}







              
            
!
999px

Console