Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

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





<!-- progress circle -->
<div class="progress-circle-container">
  <svg class="progress-circle" viewBox="0 0 100 100">
    <circle class="progress-background" cx="50" cy="50" r="45"></circle>
    <circle class="progress-circle-bar" cx="50" cy="50" r="45"></circle>
  </svg>
  <div class="scroll-to-top">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
      <path d="M12 19V5M5 12l7-7 7 7" />
    </svg>
  </div>
</div>

              
            
!

CSS

              
                body {
  height: 3000px;
}


/* Progress bar */

.progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background-color: #f0f0f0;
  z-index: 9999;
}

.progress-bar {
  height: 100%;
  background-color: black;
  transition: all 0.3s ease;
}







/* progress circle */

.progress-circle-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-circle {
  width: 80px;
  height: 80px;
}

.progress-circle-bar {
  fill: none;
  stroke: black;
  stroke-width: 5;
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
  transform-origin: center;
  transition: stroke-dashoffset 0.3s ease;
}

.progress-background {
  fill: transparent;
  stroke: #ededed;
  stroke-width: 5;
  stroke-dasharray: none;
}


.scroll-to-top {
  position: absolute;
  height: 100%;
  width: 100%;
  background-color: black;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity 0.3s ease;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.scroll-to-top svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke: white;
  transition: all 0.1s ease;
}
              
            
!

JS

              
                // Progress bar
function updateProgressBar() {
  const progressBar = document.querySelector('.progress-bar');
  const totalHeight = document.body.scrollHeight - window.innerHeight;
  const progress = (window.pageYOffset / totalHeight) * 100;
  progressBar.style.width = progress + '%';
}

updateProgressBar(); 
window.addEventListener('scroll', updateProgressBar);
window.addEventListener('resize', updateProgressBar);




// Progress circle
function updateProgressCircle() {
  const progressElement = document.querySelector('.progress-circle-bar');
  const scrollToTopElement = document.querySelector('.scroll-to-top');
  const totalHeight = document.body.scrollHeight - window.innerHeight;
  let progress = (window.pageYOffset / totalHeight) * 283;
  progress = Math.min(progress, 283);
  progressElement.style.strokeDashoffset = 283 - progress;

  if (window.innerHeight + window.pageYOffset >= document.body.offsetHeight) {
    scrollToTopElement.style.opacity = '1';
  } else {
    scrollToTopElement.style.opacity = '0';
  }
}

function scrollToTop() {
  window.scrollTo({ top: 0, behavior: 'smooth' });
}


const scrollToTopElement = document.querySelector('.scroll-to-top');
scrollToTopElement.addEventListener('click', scrollToTop);


updateProgressCircle();
window.addEventListener('scroll', updateProgressCircle);
window.addEventListener('resize', updateProgressCircle);
              
            
!
999px

Console