123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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.

            
              <div class="progress-container">
  <div class="progress-bar js-progress-bar"></div>
</div>

<article class="article js-article">
  <h1>Lorem ipsum</h1>
  
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pulvinar rutrum arcu porttitor varius. Duis egestas, dolor ut fermentum rutrum, purus neque molestie lectus, sagittis gravida nunc lectus id metus. Aliquam molestie pellentesque dignissim. Ut elementum diam aliquet placerat iaculis. Integer id lectus tincidunt, pharetra erat sollicitudin, congue mauris. Nam rutrum accumsan risus iaculis consectetur. Sed ultrices justo vitae velit pharetra ullamcorper. Mauris accumsan sem ac velit semper, non venenatis erat lacinia. Vestibulum posuere semper ullamcorper.</p>

  <p>Pellentesque odio enim, porttitor id cursus vel, accumsan eget arcu. Vestibulum in pharetra dolor. Fusce vitae augue sed urna pretium malesuada. Donec ornare pellentesque velit, sit amet placerat odio ultricies in. Pellentesque convallis lorem et pretium consequat. In hac habitasse platea dictumst. In feugiat ultrices orci, sed scelerisque libero fringilla nec. Vestibulum non lorem lacinia, placerat augue sed, efficitur sapien. Proin facilisis turpis mi, in ornare nunc rutrum sed. Aliquam bibendum metus id condimentum accumsan.</p>

  <p>Maecenas ex turpis, efficitur et vehicula eget, placerat ut enim. Praesent non aliquet eros. Ut ut erat dolor. Ut hendrerit tortor sapien, eget suscipit urna porttitor sit amet. Vivamus posuere, dolor vitae aliquet accumsan, elit quam luctus libero, ut faucibus elit purus ut quam. Fusce non sem augue. Fusce blandit eros mi, sed egestas mi imperdiet pretium. Vivamus consectetur dolor quis elit aliquam euismod. Donec in luctus mauris. Etiam ac nibh nec erat mattis sagittis. Nunc auctor eget lacus sed tincidunt. Nam rutrum orci a blandit laoreet. Sed sodales convallis nibh, at finibus quam varius vitae. Aenean sollicitudin erat ut sapien lobortis eleifend. Nulla mattis nunc in dui fermentum, vitae pretium libero imperdiet.</p>

  <p>Nullam velit mi, pellentesque sed nunc sit amet, elementum volutpat mi. Nam feugiat iaculis orci. Nam congue fermentum consectetur. In non aliquet tortor. Ut ac ex id lectus scelerisque feugiat non eget erat. Vestibulum sed ultrices ex. Ut in tincidunt ligula. Aenean pulvinar ex nec pharetra auctor. Nullam leo nisl, imperdiet ut diam ac, vehicula dapibus eros. Vestibulum faucibus consequat bibendum. Nam ultrices justo id imperdiet hendrerit. Nulla vehicula nulla et ipsum feugiat, vel congue nisl hendrerit.</p>

  <p>Sed ac consectetur tortor. Vestibulum euismod porttitor tellus non fringilla. Phasellus a felis fermentum, faucibus mi in, scelerisque ligula. Quisque quis lectus neque. Nullam ut lacus lorem. Nunc eget euismod nisi. Donec dui nunc, scelerisque vitae dictum sit amet, consequat eu urna. Nam varius quam nec quam facilisis, in fringilla leo tincidunt.</p>
</article>
            
          
!
            
              .progress-container {
  position: fixed;
  top: 0;
  left: 50%;
  
  width: 600px;
  padding: 10px;
  
  background-color: #eee;
  -webkit-transform: translateX(-50%);
          transform: translateX(-50%);
}

.progress-bar {
  width: 0%;
  height: 10px;

  background-color: #df5b57;
  
  -webkit-transition: width .25s ease;
          transition: width .25s ease; 
}

.article {
  margin-top: 80vh;
  margin-bottom: 80vh;
}
            
          
!
            
              var article = document.querySelector('.js-article');
var progressbar = document.querySelector('.js-progress-bar');

var getHeight = function () {
  return article.offsetHeight;
};

var getValue = function () {
  return (window.innerHeight * 0.75) - (article.offsetTop - window.scrollY);
};

var getPercentage = function () {
  var percentage = (getValue() / getHeight()) * 100;
  return Math.max(0, Math.min(100, percentage));
};

var onScroll = function () {
  progressbar.style.width = this.getPercentage() + '%';
};

window.addEventListener('scroll', onScroll);
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console