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

              
                <div class="layer background">
	<img src="https://assets.codepen.io/85648/night-sky_bg-01-01.svg" alt="" />
</div>
<div class="layer mid">
	<img src="https://assets.codepen.io/85648/night-sky_mid-01-01.svg" alt="" />
</div>
<div class="layer foreground">
	<img src="https://assets.codepen.io/85648/night-sky_foreground-01-01.svg" alt="" />
</div>
<div class="layer foreground-2">
	<img src="https://assets.codepen.io/85648/village-02.svg" alt="" />
</div>

<div class="grid">
	<div class="scroll-container">
		<h1>Happy holidays!</h1>
		<p>Scroll this container to see the background animation!</p>
		<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eveniet aliquam in vel nam corporis labore dignissimos eaque perferendis mollitia voluptatibus officia ad sit, eligendi, quo accusamus aliquid facilis doloremque. Eveniet.</p>
		<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Adipisci alias laborum eius temporibus, assumenda, accusantium beatae perferendis voluptatem sequi totam quos. Doloribus id facere ut dolore animi. Earum, repudiandae iure?</p>
		<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Minima vitae explicabo a minus consequatur magnam perspiciatis velit similique aperiam non harum at ipsa tenetur vero, et deserunt odit fuga! Eos.</p>
		<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat molestiae quaerat qui et dicta nam, nisi voluptas in perspiciatis sed fugit nostrum eos esse ipsam cum soluta pariatur rerum laboriosam.</p>
		<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat molestiae quaerat qui et dicta nam, nisi voluptas in perspiciatis sed fugit nostrum eos esse ipsam cum soluta pariatur rerum laboriosam.</p>
		<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente quaerat voluptatibus beatae, nesciunt magnam debitis ipsum ipsam unde velit corrupti consequuntur, ratione consectetur impedit nobis dignissimos. Saepe, est. Blanditiis, facilis!</p>
	</div>
</div>
              
            
!

CSS

              
                :root {
	--translate: 100px;
}

body {
	timeline-scope: --progress;
}

.scroll-container {
	overflow-y: scroll;
	scroll-timeline: --progress;
}

.layer {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100vh;
}

.mid {
	--translate: 150px;
}

.foreground {
	--translate: 200px;
}

.foreground-2 {
	--translate: 300px;
}

.foreground-2 img {
	height: auto;
	position: absolute;
	bottom: 0;
}

@media (prefers-reduced-motion: no-preference) {
	.layer {
		height: calc(100vh + var(--translate));
		animation: parallax linear forwards;
		animation-timeline: --progress;
	}
}

@keyframes parallax {
	from { transform: 0; }
	to { transform: translateY(calc(var(--translate) * -1)); }
}

@layer base {
	* {
		box-sizing: border-box;
	}
	
	body {
		--pad: clamp(1rem, 2vw, 5rem);
		
		font-family: Merriweather, serif;
		font-size: 1.2rem;
		line-height: 1.6;
		min-height: 300vh;
		margin: 0;
		background: radial-gradient(circle at 50% 120vh, lavender, hotpink, darkviolet, #161388, navy);
		background-attachment: fixed;
	}
	
	img {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	
	p:first-of-type {
		background: pink;
		font-weight: 700;
		width: fit-content;
	}
	
	.grid {
		max-width: 1600px;
		margin: 0 auto;
	}
	
	.scroll-container {
		max-height: min(100%, 600px);
		background: white;
		border-radius: 0.4rem;
		border: 4px solid;
		position: relative;
		padding: var(--pad);
		overflow-y: scroll;
	}
	
	@media (min-width: 600px) {
		.grid {
			height: 100vh;
			display: grid;
			position: fixed;
			grid-template-columns: 1fr 1fr;
			gap: var(--pad);
			padding: var(--pad);
		}
		
		.scroll-container {
			grid-column: 2;
		}
	}
}

              
            
!

JS

              
                
              
            
!
999px

Console