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

              
                <div class='inner'>
  <div style='height: 360px;'></div>
<section class='wise-lines'>
  <h1>How to be a good coder?</h1>
  <h1>Hey wait!</h1>
  <h1>Want to be a coder?</h1>
  <h1>Or a creator?</h1>
  <h1>You create with code.</h1>
  <h1>Though creating is more than just code.</h1>
  <h1>Imagine it in your mind before you write.</h1>
  <h1>Let your codes complement your imagination</h1>
  <h1>Not perfect? Don't worry, just keep on going</h1>
  <h1>When you imagine stuff you have reasons to write codes</h1>
  <h1>What is it anyway without real world application or experiments?</h1>
  <h1>Just zero and ones!</h1>
</section>
  <div style='height: 360px;'></div>
</div>
              
            
!

CSS

              
                body {
  max-width: 960px;
  margin: 0 auto;
}

.inner {
  padding: 5em 2em;
}

.wise-lines h1 {
  font-family: 'Playfair Display', serif;
  font-weight: 400;
  font-size: 2.5em;
  margin: 1em 0;
  transition: 0.5s all ease-in-out;
}
              
            
!

JS

              
                $(document).ready(function(){
  
  // The farther from the center the smaller it is
  
  $(window).on('scroll', function(){
    var windowHeight = $(this).height();
    var center = Math.floor(windowHeight / 2);
    var initialSize = 2;
    
    // Check how far is it away from the center
    $('.wise-lines h1').each(function(e){
      var howFar = $(this).offset().top - $(window).scrollTop();
      /*
      if (howFar < windowHeight && howFar >= 0) {
        var finalPercentage = Math.abs(( (Math.abs(howFar) / center) * 100 ));
        var setSize = finalPercentage * initialSize / 2 ;
        $(this).css({'fontSize': setSize});
      }
      */
      
      if (howFar < windowHeight && howFar >= 0) {
        if ( Math.abs(howFar - center) < 20 ) {
          $(this).css({"fontSize": "3.2em"});
        }
        else {
          $(this).css({"fontSize": "1.2em"});
        }
      }
      else {
        $(this).css({"fontSize": "1.2em"});
      }
      
    });
    
  });
  
  
});
              
            
!
999px

Console