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.

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

            
              <div class="main_content">
  <div class="fake_content one">
    <h2>Fake content</h2>
  </div>
  <div class="real_content">
    <div class="media_content">
      <div class="big_media">
        <img src="http://via.placeholder.com/1000x633" alt="big media">
      </div>
      <div class="smalls_media">
        <div class="square">
          <img src="http://via.placeholder.com/400x400" alt="square">
        </div>
        <div class="square">
          <img src="http://via.placeholder.com/400x400" alt="square">
        </div>
      </div>
      <span class="title_media back">Motion</span>
      <span class="title_media front">Developement</span>
    </div>
  </div>
  <div class="fake_content two">
    <h2>Fake content</h2>
  </div>
</div>
            
          
!

CSS

            
              @import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,700,800)

$primary: #E35205
$black: #000000
$white: #FFFFFF

img
  box-sizing: border-box
  border: 2px solid $primary

body
  margin: 0
  padding: 0

.main_content
  width: 100%
  margin: 0 auto
  font-family: 'Open sans', sans-serif
  
.fake_content
  display: flex
  justify-content: center
  align-items: center
  width: 100%
  background-color: rgba($primary, 0.8)
  
  &.one
    height: 800px
    
  &.two
    height: 1200px
    
  h2
    font-size: 80px
    line-height: 80px
    text-transform: uppercase
    font-weight: 800
    color: $white
    
.real_content
  width: 100%
  padding: 100px 100px 140px 100px //100 + 40px from transform
  box-sizing: border-box
  
.media_content
  position: relative
  display: flex
  align-items: flex-end
  
.title_media
  position: absolute
  display: block
  font-size: 150px
  line-height: 150px
  letter-spacing: -10px
  text-transform: uppercase
  font-weight: 800
  color: $black
  margin: 0
  left: 50%
  will-change: transform //IE like this
  
.front
  //top: 20px
  top: 260px

.back
  top: 120px
  //top: -100px
  //z-index: -1

.big_media
  //width: 60%
  img
    display: block
    max-width: 100%
    height: auto
  
.smalls_media
  width: 40%
  display: flex //Take care of flex in flex compatibility
  transform: translate(-100px, 40px)
  
  .square
    align-self: flex-end
    margin: 0 50px 0 0
    img
      display: block
      max-width: 100%
      height: auto
            
          
!

JS

            
              $(document).ready(function($){
  
  //set DOM variables
  var $realContent = $('.real_content'),
      $titleFrontMedia = $('.title_media.front'),
      $titleBackMedia = $('.title_media.back');
  
  //set scrolling variables
  var scrollDelta = 2,
      scrollOffset = -1000;
  
  //set offset variables
  var offsetTopRealContent = $realContent.offset().top,
      realContentHeight = $realContent.outerHeight(),
      offsetBottomRealContent = offsetTopRealContent + realContentHeight;
  
  $(window).on('scroll', function(){
    var currentTop = $(window).scrollTop();
    
    if (currentTop >= (offsetTopRealContent + scrollOffset) && currentTop <= offsetBottomRealContent){
      // requestAnimationFrame
      titleAnimation(currentTop);
    }
    
  });
  
  function titleAnimation(currentTop){
    
    var transformNegativeTranslate = "translate(-" + currentTop/scrollDelta + "px, 0)",
        transformNegativeFasterTranslate = "translate(-" + currentTop/(scrollDelta+2) + "px, 0)";
        //transformPositiveTranslate = "translate(+" + currentTop/scrollDelta + "px, 0)";
     
    $titleFrontMedia.css({"-moz-transform" : transformNegativeFasterTranslate, "-webkit-transform" : transformNegativeFasterTranslate});
    $titleBackMedia.css({"-moz-transform" : transformNegativeTranslate, "-webkit-transform" : transformNegativeTranslate});
   
  }
  
});
            
          
!
999px

Console