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 id="header" class="page-header">
	<h1>This fades out</h1>
</header>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Sagittis vitae et leo duis ut diam. Senectus et netus et malesuada fames. Vitae nunc sed velit dignissim sodales. Ultrices eros in cursus turpis. Volutpat lacus laoreet non curabitur gravida arcu ac tortor dignissim. Porttitor eget dolor morbi non arcu risus quis varius quam. Vitae aliquet nec ullamcorper sit amet risus nullam. Lacus viverra vitae congue eu consequat ac felis donec. Tincidunt id aliquet risus feugiat. Dolor magna eget est lorem ipsum dolor sit amet consectetur. Ultrices eros in cursus turpis massa tincidunt dui ut. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim. Senectus et netus et malesuada fames ac. Vel risus commodo viverra maecenas accumsan. Nulla facilisi cras fermentum odio eu feugiat pretium. Eget sit amet tellus cras adipiscing enim eu turpis egestas. Nec tincidunt praesent semper feugiat nibh sed. Eget mi proin sed libero. Velit scelerisque in dictum non consectetur a erat nam.</p>

<p>Nec ullamcorper sit amet risus nullam. Scelerisque viverra mauris in aliquam sem. Nunc sed augue lacus viverra vitae congue. Risus nec feugiat in fermentum posuere. Vel pharetra vel turpis nunc eget lorem dolor. Nullam non nisi est sit amet facilisis magna etiam tempor. Natoque penatibus et magnis dis parturient montes. Euismod elementum nisi quis eleifend quam adipiscing. Sit amet consectetur adipiscing elit duis tristique. A scelerisque purus semper eget duis at tellus at urna. Elit sed vulputate mi sit amet. Sit amet cursus sit amet dictum sit amet. Sapien faucibus et molestie ac feugiat sed. Id aliquet risus feugiat in ante metus dictum at. Vitae nunc sed velit dignissim. Magna fringilla urna porttitor rhoncus dolor purus non. Id neque aliquam vestibulum morbi blandit cursus risus at ultrices.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Sagittis vitae et leo duis ut diam. Senectus et netus et malesuada fames. Vitae nunc sed velit dignissim sodales. Ultrices eros in cursus turpis. Volutpat lacus laoreet non curabitur gravida arcu ac tortor dignissim. Porttitor eget dolor morbi non arcu risus quis varius quam. Vitae aliquet nec ullamcorper sit amet risus nullam. Lacus viverra vitae congue eu consequat ac felis donec. Tincidunt id aliquet risus feugiat. Dolor magna eget est lorem ipsum dolor sit amet consectetur. Ultrices eros in cursus turpis massa tincidunt dui ut. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim. Senectus et netus et malesuada fames ac. Vel risus commodo viverra maecenas accumsan. Nulla facilisi cras fermentum odio eu feugiat pretium. Eget sit amet tellus cras adipiscing enim eu turpis egestas. Nec tincidunt praesent semper feugiat nibh sed. Eget mi proin sed libero. Velit scelerisque in dictum non consectetur a erat nam.</p>
              
            
!

CSS

              
                body {
	padding: 40px;
	margin: 0;
	font-family: sans-serif;
	background-color: #FFF3E0;
}

.page-header {
	background-color: #FF8A5B;
	border-radius: 16px;
	padding: 100px 40px;
	margin-bottom: 40px;
}

h1 {
	margin: 0;
	color: white;
	font-size: 42px;
	text-align: center;
	font-family: sans-serif;
}

p {
	font-size: 16px;
	line-height: 1.3;
}
              
            
!

JS

              
                var header = document.getElementById('header');

function fadeOutOnScroll(element) {
	if (!element) {
		return;
	}
	
	var distanceToTop = window.pageYOffset + element.getBoundingClientRect().top;
	var elementHeight = element.offsetHeight;
	var scrollTop = document.documentElement.scrollTop;
	
	var opacity = 1;
	
	if (scrollTop > distanceToTop) {
		opacity = 1 - (scrollTop - distanceToTop) / elementHeight;
	}
	
	if (opacity >= 0) {
		element.style.opacity = opacity;
	}
}

function scrollHandler() {
	fadeOutOnScroll(header);
}

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

Console