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

              
                <p class="cool">
	<span data-text="Hello,">Hello,</span>
	<span data-text="I'm">I'm</span>
	<span data-text="the">the</span>
	<span data-text="text.">text.</span>
	<span data-text="How">How</span>
	<span data-text="are">are</span>
	<span data-text="you,">you,</span>
	<span data-text="pal?">pal?</span>
</p>	
              
            
!

CSS

              
                :root {
	--background: #f3a683;
	--base: #303952;
	--accent: #786fa6;
	--shadow: #e77f67;
}

html {
	background: var(--background);
	display: grid;
	height: 100%;
	place-items: center;
}

.cool {
	font: bold 3rem/1.2 sans-serif;
	max-width: 20rem;

	span {
		color: var(--shadow);
		display: inline-block;
		position: relative;

		// Setting the stagger "by hand". You have to know the number of children beforehand and loop through them all, or set staggers only for a number of first children. Or set it with js
		@for $i from 1 through 10 {
			&:nth-child(#{$i}) {
				&::before,
				&::after {
					animation-delay: #{$i / 10}s;
				}
			}
		}

		// make the font black again if no animation is playing
		@media (prefers-reduced-motion) {
			color: var(--base);
		}

		// the magic, kinda
		&::before {
			animation: max-height .4s cubic-bezier(0.61, 1, 0.88, 1) 1 normal both;
			color: var(--accent);
		}
		
		&::after {
			animation: max-width .7s cubic-bezier(0.61, 1, 0.88, 1) 1 normal both;
			color: var(--base);
		}
		
		&::before,
		&::after {
			// Using data attribute to avoid duplicated content in HTML. It has a very good support when used in the content property https://caniuse.com/mdn-css_types_attr
			content: attr(data-text);
			left: 0;
			// The overflowing text is cut off
			overflow: hidden;
			position: absolute;
			// Set the speak property to none, because we don't want screen readers to read every word in the paragraph twice. "Hello, hello"? No!
			speak: none;

			// In this case we just don't animate things, BUT we can maybe animate opacity only since reduced motion != no motion
			@media (prefers-reduced-motion) {
				animation: none;
				content: "";
			}
		}
	}
}

@keyframes max-width {
	from {
		max-width: 0;
	}
	to {
		max-width: 100%;
	}
}

@keyframes max-height {
	from {
		max-height: 0;
	}
	to {
		max-height: 100%;
	}
}
              
            
!

JS

              
                
              
            
!
999px

Console