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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <main>
	<article>
		<h1>HTML Ipsum Presents</h1>

		<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>

		<h2>Header Level 2</h2>

		<ol>
			<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
			<li>Aliquam tincidunt mauris eu risus.</li>
		</ol>

		<blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>

		<h3>Header Level 3</h3>

		<ul>
			<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
			<li>Aliquam tincidunt mauris eu risus.</li>
		</ul>

		<pre class="is-animated"><code>
#header h1 a {
	display: block;
	width: 300px;
	height: 80px;
}
		</code></pre>
		
		<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>

		<h2>Header Level 2</h2>

		<ol>
			<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
			<li>Aliquam tincidunt mauris eu risus.</li>
		</ol>

		<blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>

		<h3>Header Level 3</h3>

		<ul>
			<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
			<li>Aliquam tincidunt mauris eu risus.</li>
		</ul>
		
		<pre class="is-animated"><code>
#header h1 a {
	display: block;
	width: 300px;
	height: 80px;
}
		</code></pre>
		
		<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>

		<h2>Header Level 2</h2>

		<ol>
			<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
			<li>Aliquam tincidunt mauris eu risus.</li>
		</ol>

		<blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>

		<h3>Header Level 3</h3>

		<ul>
			<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
			<li>Aliquam tincidunt mauris eu risus.</li>
		</ul>
		
		<pre class="is-animated"><code>
#header h1 a {
	display: block;
	width: 300px;
	height: 80px;
}
		</code></pre>
	</article>
</main>
              
            
!

CSS

              
                // in this case I'm going to make all animated elements fade in & up
// I've found that .7 sections is ample time for users to see the animation in most cases
.is-animated {
	opacity: 0;
	transform: translateY(35%);
	transition: opacity .7s, transform .7s;
	
	&.scrolled-into-view {
		opacity: 1;
		transform: translateY(0);
		transition: opacity .7s, transform .7s;
	}
	
	// you could also do the same thing with the "one time" animation, I'll leave it commented out though (you may have to refresh to use this)
	// &.scrolled-into-view-first-time {
	// 	opacity: 1;
	// 	transform: translateY(0);
	// }
}


// simple article stylings
article {
	width: 700px;
	margin: 100px auto;
	font-family: sans-serif;
	
	h1, h2, h3, h4, h5, h6 {
		margin-bottom: 0.5em;
	}
	
	h1 { font-size: 2.5rem; }
	h2 { font-size: 2rem; }
	h3 { font-size: 1.75rem; }
	h4 { font-size: 1.5rem; }
	h5 { font-size: 1.25rem; }
	h6 { font-size: 1.25rem; }
	
	p {
		margin-bottom: 1em;
		font-size: 1rem;
		line-height: 1.4em;

		&:last-child { margin-bottom: 0; }

		a { color: inherit; }
	}
	
	strong { font-weight: bold; }
	em { font-style: italic; }
	
	ul {
		list-style: disc;
		margin: 1em 0;
		padding-left: 25px;

		li {
			font-size: 1rem;
			line-height: 1.2em;
			margin-bottom: 0.2em;

			a { color: inherit; }
		}

		&:first-child { margin-top: 0; }
		&:last-child { margin-bottom: 0; }
	}
	
	ol {
		list-style: decimal;
		margin: 1em 0;
		padding-left: 25px;

		li {
			font-size: 1rem;
			line-height: 1.2em;
			margin-bottom: 0.2em;

			a { color: inherit; }
		}

		&:first-child { margin-top: 0; }
		&:last-child { margin-bottom: 0; }
	}
	
	blockquote {
		border-top: 1px solid black;
		border-bottom: 1px solid black;
		padding: 25px 0;
		margin: 1em 0;
		
		&:first-child { margin-top: 0; }
		&:last-child { margin-bottom: 0; }
	}
	
	pre {
		display: block;
		background: lightgray;
		padding: 15px 25px;
		margin: 1em 0;
		
		&:first-child { margin-top: 0; }
		&:last-child { margin-bottom: 0; }
	}
	
	code {
		font-family: monospace;
	}
}
              
            
!

JS

              
                // create our new observer, we want the trigger point of elements to be when the element is 25% visible.
// you could create multiple observers with different thresholds if necessary
let observer = new IntersectionObserver( isElScrolledIntoView, { root: null, rootMargin: '0px', threshold: 0.25 } );

// grab our elements, this will be a global class for animating elements
const elements = document.querySelectorAll('.is-animated');

// loop over all elements and observe each of them
elements.forEach( element => {
	observer.observe(element);
});

// create our "what to do with each observed element" function
function isElScrolledIntoView( entries ) {
	// again loop over all entries (element)
	entries.forEach( entry => {
		// check if the entry is intersecting at our set threshold
		if ( entry.isIntersecting ) {
			// set a class to toggle animation
			entry.target.classList.add('scrolled-into-view');
			// if we only want to play the animation once per page, let's also add a class for that
			entry.target.classList.add('scrolled-into-view-first-time');
		} else {
			// if we've stopped intersecting, let's remove the animation
			entry.target.classList.remove('scrolled-into-view');
		}
	});
}
              
            
!
999px

Console