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

              
                <nav>
  <div>Page <span>(or section)</span> Transitions Demo with Greensock</div>
    <ul>
      <li><a href="#" data-page="page1">One</a></li>
      <li><a href="#" data-page="page2">Two</a></li>
      <li><a href="#" data-page="page3">Three</a></li>
      <li><a href="#" data-page="page4">Four</a></li>
    </ul>
  </nav>

  <section class="active" id="page1">
    <div>
      <h1>PAGE 1</h1>
      <img src="http://cocosavant.com/cp-img/car-street.jpg" />
    </div>
  </section>

  <section id="page2">
    <div>
      <h1>PAGE 2</h1>
      <div>
        <h3>Pie chocolate bar tart</h3> jujubes jujubes donut. Chocolate cake chocolate liquorice cake oat cake fruitcake wafer cookie. Bear claw jelly lollipop jelly-o biscuit brownie chupa chups marzipan topping. Halvah liquorice caramels chocolate cake.</div>
      <img src="http://cocosavant.com/cp-img/vintage-cars.jpg" />
    </div>
  </section>

  <section id="page3">
     <div>
      <h1>PAGE 3</h1>
      <img src="http://cocosavant.com/cp-img/tall-bldgs.jpg" />
    </div>
  </section>

  <section id="page4">
     <div>
      <h1>PAGE 4</h1>
      <img src="http://cocosavant.com/cp-img/gear-shift.jpg" />
    </div>
  </section>
              
            
!

CSS

              
                html, body {
  height: 100%;
  padding: 0;
  margin: 0;
  background: #2C3E50;
} 

body {
  font-family: arial, sans-serif;
}

section {
  background-color: #4c6f5d;
  color: #bdbdbd;
  float: left;
  padding: 20px 0;
  position: absolute;
  text-align: center;
  width: 100%;

  &.active {
    opacity: 1;
    position: relative;
    z-index: 10;
  }
  
  #page2 {
    img {
      display: inline-block;
      width: 50%;
    }
  }
  
  > div {
    margin: auto;
    min-height: 330px;  
    min-width: 400px;
    
    div {
      float: left;
      line-height: 1.2;
      margin: 20px;
      text-align: left;
      width: 50%;
    }
  }
    
  h3 {
    text-transform: uppercase;
  }
} 

nav {
  color: #bdbdbd;
  letter-spacing: 1px;
  min-height: 10vh;
  text-transform: uppercase;
  width: 100%; 

  div {
    font-size: 30px;
    font-weight: 800;
    padding: 30px 20px 10px 20px;
    vertical-align: middle;
    
    span {
      font-size: 20px;
      text-transform: none
    }
  }
}
  
ul {
  background: #2a2b30;

  li {
    display: inline-block;
    line-height: 11vh;
    padding: 10px 0;
    margin: 0;

    a {
      display: block; 
      padding: 0 40px;
      color: #bdbdbd;
      text-decoration: none;
      border-right: 1px solid #1f1f1f;

      &:hover { 
        color: #5c5edc;
      } 
    }
  }
}
              
            
!

JS

              
                // setting the height of all the sections to be the same and take the max-height
  // plus responsive
  $(window).resize(function() {
    var maxHeight = 0; // initialize

    $('section').each(function(){
      // capture height for each section
      if ($(this).height() > maxHeight) {
        // make this height the max height .. until you get to the max height
        maxHeight = $(this).height();
      }
    });

    $('section').height(maxHeight);

  }).resize();


  $('nav ul li a').on('click', function(e) {

    var linkID = $(this).attr('data-page');
    //var sectionActive = $('section.active').attr('id');
    var $sectionActive = $('section.active'),
        $sectionClicked = $('section#' + linkID),
        $sectionsNotClicked = $('section').not($sectionClicked);

    var tl = new TimelineLite({paused:true});
    
    if ( !$('section#' + linkID).hasClass('active') ) {
    
        tl.set($sectionsNotClicked,
              { opacity: 0})

          .fromTo($sectionActive, .7,
              { scale: 1, xPercent: 0, yPercent: 0, opacity: 1},
              { scale: .4, xPercent: -20, yPercent: -20, opacity: .6 }, "A")

          .fromTo($sectionClicked, .7,
              { scale: .4, xPercent: 100, yPercent: -20, opacity: 0 },
              { xPercent: 20, opacity: .6}, "A")

          .to($sectionClicked, .7,
              { scale: 1, xPercent: 0, yPercent: 0, opacity: 1}, "B" )

          .to($sectionActive, .7,
              { xPercent: -100,
                 // "this" = tween , this.target  = tweened element, add class
                 onComplete: function() {
                   $sectionActive.removeClass('active');
                   $sectionClicked.addClass('active');
                 }
              }, "B" )
          .play();
     }
      //// if we want to simply fade in/out ////
        // $sectionActive.fadeOut( 1000, function() {
        //   $(this).removeClass('active');

        //   $sectionClicked.fadeIn( 1000, function() {
        //     $(this).addClass('active');
        //   });
        // });
  });
              
            
!
999px

Console