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

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

              
                <div class="scroller"></div>
<main>
	<section class="chat">
		<div class="dialog you">
			<figure>
				<img src="https://picsum.photos/id/38/256/256" />
				<p>Scroll to see the chat.</p>
			</figure>
		</div>
		<div class="dialog me">
			<figure>
				<img src="https://picsum.photos/id/39/256/256" />
				<p>Lorem ipsum dolor sit.</p>
			</figure>
		</div>
		<div class="dialog you">
			<figure>
				<img src="https://picsum.photos/id/38/256/256" />
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat rerum non quod nulla excepturi.</p>
			</figure>
		</div>
		<div class="dialog me">
			<figure>
				<img src="https://picsum.photos/id/39/256/256" />
				<p>Lorem, ipsum.</p>
			</figure>
		</div>
		<div class="dialog you">
			<figure>
				<img src="https://picsum.photos/id/38/256/256" />
				<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate, ex rem? Sint ratione reprehenderit ut, asperiores incidunt recusandae illo soluta molestiae culpa eius.</p>
			</figure>
		</div>
		<div class="dialog me">
			<figure>
				<img src="https://picsum.photos/id/39/256/256" />
				<p>Lorem ipsum dolor sit amet!</p>
			</figure>
		</div>
		<div class="dialog you">
			<figure>
				<img src="https://picsum.photos/id/38/256/256" />
				<p>Lorem ipsum dolor sit amet.</p>
			</figure>
		</div>
		<div class="dialog me">
			<figure>
				<img src="https://picsum.photos/id/39/256/256" />
				<p>Lorem ipsum dolor sit.</p>
			</figure>
		</div>
		<div class="dialog you">
			<figure>
				<img src="https://picsum.photos/id/38/256/256" />
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat rerum non quod nulla excepturi, quam doloremque.</p>
			</figure>
		</div>
		<div class="dialog me">
			<figure>
				<img src="https://picsum.photos/id/39/256/256" />
				<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur, harum?</p>
			</figure>
		</div>
		<div class="dialog you">
			<figure>
				<img src="https://picsum.photos/id/38/256/256" />
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
			</figure>
		</div>
		<div class="dialog me">
			<figure>
				<img src="https://picsum.photos/id/39/256/256" />
				<p>Leave a like if you like this pen! xD</p>
			</figure>
		</div>
	</section>
</main>
              
            
!

CSS

              
                body {
	height: 100vh;
	overflow-x: hidden;
	overflow-y: auto;
	background-color: #333;
}

.scroller {
	width: 100%;
	height: 1000vh;
	overflow-x: hidden;
	position: relative;
	overflow-y: auto;
}

main {
	top: 0;
	position: fixed;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
	perspective: 15rem;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 2.4rem;
	
	@media only screen and (max-width: 600px) {
		font-size: 1.6rem;
	}
}

.chat {
	padding: 1rem;
	transform-style: preserve-3d;
	transform-origin: bottom center;
	transform: translateY(calc(-50% + 10rem)) translateZ(calc(100vh * var(--phase, 0))) rotateX(90deg);
	// background-color: #333;sa
	height: 100%;
	display: flex;
	flex-direction: column-reverse;
	max-width: 80rem;
	width: 100%;
	margin: 0 auto;
	position: relative;
	
	
	.dialog {
		height: 100%;
		transform: rotateX(-90deg);
		transform-origin: center bottom;
		flex: 1;
		opacity: calc(1 - var(--focal));
		display: flex;
		align-items: flex-end;
		position: relative;
		width: 100%;
		
		figure {
			display: flex;
			align-items: flex-end;
			position: absolute;
			width: 100%;
			
			img {
				width: 5rem;
				height: 5rem;
				border-radius: 5rem;
				margin-inline-end: 1rem;
				border: solid 1px rgba(0, 0, 0, 0.3);
			}

			p {
				background-color: lightsteelblue;
				padding: 2rem;
				@media only screen and (max-width: 600px) {
					padding: 1rem;
				}
				border-radius: .5rem;
				max-width: 60%;
				border: solid 1px rgba(0, 0, 0, 0.3);
				color: rgba(0, 0, 0, 0.7);
			}
		}
		
		&.me {
			justify-content: flex-end;
			
			img {
				margin-inline-end: 0;
				margin-inline-start: 1rem;
			}
			
			figure {
				flex-direction: row-reverse;
				
				p {
					background-color: palegoldenrod;
				}
			}
		}
	}
}
              
            
!

JS

              
                const chats = [...document.querySelectorAll('.chat .dialog')];

const onScroll = _ => {
	const { scrollTop, scrollHeight, clientHeight } = document.scrollingElement;
	const phase = scrollTop / (scrollHeight - clientHeight);
	document.body.style.setProperty('--phase', phase);
	
	chats.forEach((e, i) => {
		const step = 1 / chats.length;
		const focalPoint = step * (i - 1);
		const focal = Math.min(Math.max(1 - (phase - focalPoint) / step, -1), 1);
		e.style.setProperty('--focal', focal);
		e.style.opacity = Math.min(Math.max(1 + focal * 2, 0), 1);
		
		const dist = (phase - step * i) / step;
		e.style.filter = `blur(${Math.min(Math.abs(dist ** 2 * 0.5), 1.2)}rem)`;
	});
};

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

Console