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

              
                p Scroll down to see the scroll indicators change
 span (Still experimental!)
.progress-percentage 0.0000 %
.progress-vertical
.progress-horizontal
svg.progress-wheel(viewBox="0 0 100 100")
 circle(cx="50" cy="50" r="40")/
              
            
!

CSS

              
                :root {

	/* Animation progress */
	--scroll-pos: 0;

}

:root, body {
	margin: 0;
	padding: 0;
	background: #222;
}

body 
{ height: 10000px; }

p, .progress-percentage {
	position: fixed;
	left: 25px;
	top: 25px;
	font: 20px Helvetica, Arial, sans-serif;
	color: #ddd;
}
p span {
	display: block;
	font-size: .8em;
}

.progress-percentage {
	top: 125px;
}



/* ===== Circular progress bar ===== */

.progress-wheel {
	position: fixed;
	left: 150px;
	top: 150px;
	width: 100px;
	height: 100px;
	fill: transparent;
	stroke: blue;
	stroke-width: 5;
	--circumfence: calc(2 * 3.14 * 40);
	stroke-dasharray: var(--circumfence);
	stroke-dashoffset: var(--circumfence);
	
	/* The next two declarations pretty much do the trick */
	
	/* First set a paused animation running for 100 seconds */
	animation: progress-wheel linear paused 100s;
	
	/* Inspired by the following article:
	https://css-tricks.com/starting-css-animations-mid-way/
	
	...we can run an animation manually step by step by
	playing with a negative delay value. 

	Then a variable to the delay value to make it reflect
	the current scroll position. */
	animation-delay: calc(calc(var(--scroll-pos) - 1) * -1s);
}
@keyframes progress-wheel {
	99%, 100% { 
		stroke-dashoffset: 0;
	}
}



/* ===== Horizontal progress bar ===== */

.progress-horizontal {
	position: fixed;
	left: 0;
	right: 0;
	top: 0;
	width: 100%;
	height: 10px;
	background: rgba(255,255,255,.2);
}
.progress-horizontal::before {
	content: "";
	position: absolute;
	left: 0;
	width: 0;
	width: 100%;
	height: 100%;
	background: blue;
	transform-origin: 0;

	animation: progress-horizontal linear paused both 100s;
    animation-delay: calc(var(--scroll-pos) * -1s);
}
@keyframes progress-horizontal {
	from { transform: scaleX(0); }
	to { transform: scaleX(1); }
}



/* ===== Vertical progress bar ===== */

.progress-vertical {
	position: fixed;
	left: 0;
	top: 0;
	bottom: 0;
	width: 8px;
	height: 100vh;
	background: 
		repeating-linear-gradient(
			to bottom,
			transparent 0,
			transparent calc(10vh - 2px),
			#fff calc(10vh - 2px),
			#fff 10vh
		);
}
.progress-vertical::before {
	content: '';
	position: absolute;
	left: 0;
	display: block;
	width: 5px;
	height: 100%;
	background: 
	repeating-linear-gradient(
			to bottom,
			transparent 0,
			transparent calc(1vh - 1px),
			#fff calc(1vh - 1px),
			#fff 1vh
		);
}

.progress-vertical::after {
	content: '';
	position: fixed;
	left: 0;
	top: 0;
	width: 15px;
	height: 3px;
	background: blue;
	
	animation: progress-vertical linear paused both 100s;
    animation-delay: calc(var(--scroll-pos) * -1s);
}
@keyframes progress-vertical {
	from { transform: translateY(0); }
	to { transform: translateY(calc(100vh - 2px)); }
}
              
            
!

JS

              
                const root = document.documentElement
const body = document.body

const totalScrollDistance = () =>
    body.clientHeight - window.innerHeight || 1

const scrollProgress = scrollPos => 
    (scrollPos / totalScrollDistance() * 100).toFixed(4)

const updateCSSvar = scrollPos =>
    root.style.setProperty('--scroll-pos', scrollProgress(scrollPos))

const displayProgress = scrollPos => {
    const element = document.querySelector('.progress-percentage')
    element.innerHTML = `${scrollProgress(scrollPos)} %`
}

window.addEventListener('scroll', () => {
    const scrollPos = window.pageYOffset
    updateCSSvar(scrollPos)
    displayProgress(scrollPos)
})

              
            
!
999px

Console