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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                .container
  - for (var i = 0; i < 12; ++i)
    article.excerpt
      .excerpt__inner
        figure.excerpt__image(style='background-image:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/22914/6850716805_05b85349fa_b.jpg);')
        .excerpt__content
          h1.excerpt__title Good stuff happening
          .excerpt__entryContent
            p Just waking up in the morning gotta thank God I don't know but today seems kinda odd No barking from the dogs, no smog And momma cooked a breakfast with no hog. I got my grub on, but didn't pig out. Finally got a call from a girl want to dig out. Hooked it up on later as I hit the do', Thinking will i live another twenty fo'. I gotta go cause I got me a drop top And if I hit the switch, I can make the ass drop. Had to stop at a red light. Looking in my mirror not a jacker in sight And everything is alright.

              
            
!

CSS

              
                @import 'breakpoint';

* {
  box-sizing: border-box;
}

$desktop: 960px;

body {
  color: #444;
}

h1,h2,h3,h4,h5,h6 {
  font-family: 'industry', sans-serif;
  font-weight: 300;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2em 1.25em;
  
  @include breakpoint($desktop) {
    padding: 0em 1.25em;
  }
}

.excerpt {
  
  & { 
    height: auto;
    width: 100%;    
    margin-bottom: 1.25em;
    
    @include breakpoint($desktop) {
      height: 400px;
      width: 100%;  
      margin-bottom: 0;
    }
  }
  
  &__inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: #ececec;
    border: 1px solid #ccc;
    box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
    
    @include breakpoint($desktop) {
      flex-direction: row;
      box-shadow: none;
    }
  }
  
  &__image {
    width: 100%;
    height: 240px;
    background-color: #e1e1e1;
    margin: 0;
    background-size: cover;
    background-position: center;
    
    @include breakpoint($desktop) {
      width: 50%;
      height: 100%;
    }
  }
  
  &__content {
    width: 100%;
    padding: 1em 1.25em;
    
    @include breakpoint($desktop) {
      width: 50%;
      padding: 1em 2em;
    }
  }
  
  &__title {
    margin: 0;
  }
  
  &__entryContent {
    font-size: 0.875em;
    line-height: 1.5;
    display: none;
    
    @include breakpoint($desktop) {
      display: block;
    }
  }
}


              
            
!

JS

              
                var AnimateExcerpts = function() {
  
  var 
    excerpts,
    excerptsInner
  
  var _init = function() {
    excerpts = document.querySelectorAll('.excerpt');
    excerpts = Array.prototype.slice.call(excerpts);
    excerptsInner = document.querySelectorAll('.excerpt__inner');
    excerptsInner = Array.prototype.slice.call(excerptsInner);
    _prepare();
    _addEventHandlers();
    _inView();
  }
  
  var _addEventHandlers = function() {
    window.addEventListener('scroll', _inView, false);
    window.addEventListener('resize', _inView, false);
  }
  
  var _prepare = function() {
    TweenLite.set(excerptsInner, {transformPerspective: 900})
  }
  
  var _inView = function() {   
    excerpts.forEach(function(element,index) {
      _animateInOut(element, index);
    });
  }
  
  var _animateInOut = function(element, index) {
    var inner               = element.children[0];      
    var pos                 = element.getBoundingClientRect();
    var elHeight            = pos.height;
    var elBottomFromTop     = pos.bottom;
    var elTopFromTop        = pos.top;
    var elTopFromBottom     = pos.top - window.innerHeight;
    var elBottomFromBottom  = pos.bottom - window.innerHeight;

    if( elTopFromTop <= 0 && elBottomFromTop >= 0 ) { 
      var transformOffset   = (elTopFromTop / elHeight) * -50;
      TweenLite.to(inner, 0.3, {
        rotationX: transformOffset,
        transformOrigin: '50% 100%', 
        ease:Power2.easeOut
      });
    } 
    else if( elTopFromBottom <= 0 && elBottomFromBottom >= 0 ) {
      var transformOffset   =   (elBottomFromBottom / elHeight) * -50;
      TweenLite.to(inner, 0.3, {
        rotationX: transformOffset,
        transformOrigin: '50% 0%', 
        ease:Power2.easeOut
      });
    }
    else {
      TweenLite.to(inner, 0.1, {rotationX:0, ease:Linear.easeNone})
    }
  } 
  
  return {
    init: _init
  }
}();

AnimateExcerpts.init();
              
            
!
999px

Console