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 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

              
                <header>
  <p class="logo">Logo</p>
  
  <!--   progress bar -->
  <div class="progress-bar">
    <!--     indicator -->
    <div class="indicator"></div>
  </div>
</header>

<main class="article">
  <h1 class="title">
    It was going to be a beautiful ride
  </h1>
  
  <section class="author">
    <div class="author_img"></div>
    <div class="author_detail">
      <p>Chloe Hwang</p>
      <p>Feb 6, 2019</p>
    </div>
  </section>
  
  <section>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor mauris lobortis, blandit massa sed, ultrices est. Maecenas tristique, tellus quis ullamcorper vestibulum, ante diam auctor justo, et tempor quam massa et mi. Aliquam vestibulum eros a velit consectetur, non consequat augue viverra. Proin pharetra sem nunc. Proin in erat tortor. Aenean feugiat vitae nulla sed mattis. Nunc et tempor velit.</p>
    <p>Integer aliquet tellus id risus maximus, eget aliquet urna commodo. Maecenas sodales hendrerit ex et scelerisque. Sed posuere nisl libero, vel blandit lacus tristique quis. Integer nunc nulla, egestas nec massa rutrum, aliquam ullamcorper est. Maecenas a mollis ligula. Integer odio ex, aliquet nec diam ac, interdum interdum dolor. Sed ac rutrum augue.</p>
    <p>Integer ac pretium eros. Vivamus non neque venenatis, feugiat mi sit amet, rhoncus elit. Ut vitae lacus vulputate, feugiat libero ac, varius ex. Praesent sodales aliquet ligula. Vivamus feugiat velit porta, gravida massa eu, gravida nulla. Suspendisse ac nibh auctor, egestas felis eget, egestas enim. Donec ac porttitor quam. Nullam finibus ultricies nibh id rhoncus. Nam ac magna sit amet enim dictum faucibus.</p>
    <p>Pellentesque sit amet ultrices dolor. Suspendisse vehicula metus quis ante varius, sed varius nisi porta. Nullam vitae ligula sit amet felis sagittis ullamcorper ac eu velit. Nullam at ex nulla. Morbi nec posuere nisi. Donec rhoncus, massa ac congue vehicula, lorem odio volutpat sapien, vitae rhoncus ante lectus non felis. Nullam non commodo urna, ut cursus diam. Donec a posuere tellus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aenean ut mauris eros. Fusce non vulputate velit, sit amet finibus diam. Morbi bibendum maximus elit, ac egestas dolor pulvinar ut. Aenean et tellus vitae mi egestas pretium quis non odio. Integer mollis metus id metus mollis dignissim. Fusce malesuada est ut lectus iaculis aliquam. Fusce at libero porttitor, semper arcu sit amet, blandit turpis.</p>
    <p>Nullam laoreet, ligula in venenatis sollicitudin, quam dui vulputate lorem, ac sollicitudin leo diam et nisl. Sed facilisis leo a neque mollis, non posuere elit dapibus. Nullam non massa a felis accumsan molestie. Integer eget eros id mauris ullamcorper accumsan facilisis non est. Aenean id purus nibh. Nulla tincidunt magna nisi. Sed lobortis orci urna, nec dignissim elit eleifend sit amet. Nunc nibh sapien, porttitor in quam in, pharetra lacinia tellus. Curabitur ut est lobortis, rutrum tellus vel, efficitur arcu. In ornare consequat consectetur. Quisque ornare tempus metus, eget consequat turpis hendrerit sit amet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam vel sem tincidunt, dapibus magna eget, blandit nisl. Integer euismod aliquet ipsum, in pulvinar ipsum convallis at. Morbi tincidunt nisl eget ullamcorper ultricies.</p>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor mauris lobortis, blandit massa sed, ultrices est. Maecenas tristique, tellus quis ullamcorper vestibulum, ante diam auctor justo, et tempor quam massa et mi. Aliquam vestibulum eros a velit consectetur, non consequat augue viverra. Proin pharetra sem nunc. Proin in erat tortor. Aenean feugiat vitae nulla sed mattis. Nunc et tempor velit.</p>
    <p>Integer ac pretium eros. Vivamus non neque venenatis, feugiat mi sit amet, rhoncus elit. Ut vitae lacus vulputate, feugiat libero ac, varius ex. Praesent sodales aliquet ligula. Vivamus feugiat velit porta, gravida massa eu, gravida nulla. Suspendisse ac nibh auctor, egestas felis eget, egestas enim. Donec ac porttitor quam. Nullam finibus ultricies nibh id rhoncus. Nam ac magna sit amet enim dictum faucibus.</p>
    <p>Pellentesque sit amet ultrices dolor. Suspendisse vehicula metus quis ante varius, sed varius nisi porta. Nullam vitae ligula sit amet felis sagittis ullamcorper ac eu velit. Nullam at ex nulla. Morbi nec posuere nisi. Donec rhoncus, massa ac congue vehicula, lorem odio volutpat sapien, vitae rhoncus ante lectus non felis. Nullam non commodo urna, ut cursus diam. Donec a posuere tellus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aenean ut mauris eros. Fusce non vulputate velit, sit amet finibus diam. Morbi bibendum maximus elit, ac egestas dolor pulvinar ut. Aenean et tellus vitae mi egestas pretium quis non odio. Integer mollis metus id metus mollis dignissim. Fusce malesuada est ut lectus iaculis aliquam. Fusce at libero porttitor, semper arcu sit amet, blandit turpis.</p>
    <p>Nullam laoreet, ligula in venenatis sollicitudin, quam dui vulputate lorem, ac sollicitudin leo diam et nisl. Sed facilisis leo a neque mollis, non posuere elit dapibus. Nullam non massa a felis accumsan molestie. Integer eget eros id mauris ullamcorper accumsan facilisis non est. Aenean id purus nibh. Nulla tincidunt magna nisi. Sed lobortis orci urna, nec dignissim elit eleifend sit amet. Nunc nibh sapien, porttitor in quam in, pharetra lacinia tellus. Curabitur ut est lobortis, rutrum tellus vel, efficitur arcu. In ornare consequat consectetur. Quisque ornare tempus metus, eget consequat turpis hendrerit sit amet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam vel sem tincidunt, dapibus magna eget, blandit nisl. Integer euismod aliquet ipsum, in pulvinar ipsum convallis at. Morbi tincidunt nisl eget ullamcorper ultricies.</p>
    <p style="text-align: center;">* * *</p>
  </section>
</main>
              
            
!

CSS

              
                .progress-bar {
  background: #dfeaff;
  height: 10px;
}

.indicator {
  background: #b0ccff;
  height: inherit;
  width: 0; /* start off at 0, to be changed by JS */
}



/****** Additional styling below ******/

* {
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
  font-smoothing: antialiased;
}

body {
  font-family: "Noto Serif SC", Georgia, serif;
  margin: 0;
  overflow: hidden;
}

header {
  box-shadow: 0 4px 12px 0 rgba(0,0,0,.05);
  position: sticky;
  top: 0;
}

.logo {
  border: 1px solid #b0ccff;
  display: inline-block;
  font-family: Helvetica;
  font-size: 12px;
  letter-spacing: 0.2em;
  margin: 0.5rem 50px;
  padding: 0.5em 1em;
  text-transform: uppercase;
}

.article {
  height: calc(100vh - 53px);
  overflow-y: scroll;
  padding: 50px;
}

.article p {
  line-height: 1.6;
}

.title {
  font-size: 40px;
  margin-top: 0;
}

.author {
  display: flex;
}

.author_img {
  background: url('https://bit.ly/2SfmYqM') center;
  background-size: cover;
  border-radius: 100%;
  height: 50px;
  margin-right: 1em;
  width: 50px;
}

.author_detail p {
  font-family: Helvetica, sans-serif;
  font-size: 0.9rem;
  font-weight: 300;
  margin: 0;
}




              
            
!

JS

              
                let indicator = document.querySelector('.indicator')
let article   = document.querySelector('.article')


article.addEventListener('scroll', function() {
  // 1) Each time on scroll, recalculate the progress
  let articleHeight = article.scrollHeight - article.clientHeight // scrollable height of article
  let scrollPosition = article.scrollTop          // how far we've scrolled from the top
  let progress = scrollPosition / articleHeight   // calculate progress
  let progressPercentage = (progress * 100) + "%" // turn progress into a percentage
 
  // 2) Set width to new progress
  indicator.style.setProperty('width', progressPercentage)
})
              
            
!
999px

Console