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="block-1">
    Lorem ipsum dolor sit amet consectetur<br> adipisicing elit. Sit in quaerat hic labore <br> quidem odit dicta ea minus<br> alias! Pariatur quos nesciunt doloremque quas quisquam ipsum voluptas, temporibus <br>voluptate id.
</div>

<div class="block-2">
    Lorem ipsum dolor sit amet consectetur <br>adipisicing elit. Sit in quaerat hic labore quidem odit dicta<br> ea minus<br> alias! Pariatur<br> quos nesciunt doloremque quas quisquam ipsum voluptas, temporibus voluptate id.
</div>

<div class="block-3">
    Lorem<br> ipsum dolor sit amet consectetur adipisicing elit. <br>Sit in quaerat hic<br> labore quidem odit dicta ea minus alias! Pariatur<br> quos nesciunt doloremque quas quisquam <br>ipsum voluptas, temporibus voluptate id.
</div>


<div class="containerr">
		<section class="gallery">

			<div class="frame">
				<div class="frame__content">
					<h2>Beautiful World</h2>
				</div>
			</div>

			<div class="frame">
				<div class="frame__content">
					<div class="frame-media frame-media_left" style="background-image: url(images/1.jpg)"></div>
				</div>
			</div>

			<div class="frame frame_bg">
				<div class="frame__content">
					<video class="frame-media frame-media_right" src="media/video_optimized.mp4" autoplay loop muted></video>
				</div>
			</div>

			<div class="frame"></div>

			<div class="frame">
				<div class="frame__content text-right">
					<h3>Pure planet</h3>
					<p>Lorem ipsum dolor sit amet, consectetur elit adipisicing. Nemo fugit, rerum dolorem assumenda consequatur dicta error iure laboriosam temporibus.</p>
				</div>
			</div>

			<div class="frame frame_bg">
				<div class="frame__content">
					<div class="frame-media frame-media_left" style="background-image: url(images/2.jpg)"></div>
				</div>
			</div>

			<div class="frame"></div>

			<div class="frame frame_bg">
				<div class="frame__content">
					<div class="frame-media frame-media_right" style="background-image: url(images/3.jpg)"></div>
				</div>
			</div>

			<div class="frame"></div>

			<div class="frame">
				<div class="frame__content text-left">
					<h3>Ask the Mountains</h3>
					<p>Lorem ipsum dolor sit amet, consectetur elit. Rerum dolorem assumenda consequatur dicta error iure laboriosam temporibus omnis quae eaque aliquam esse unde accusamus dolores non soluta.</p>
				</div>
			</div>

			<div class="frame frame_bg">
				<div class="frame__content">
					<div class="frame-media frame-media_right" style="background-image: url(images/4.jpg)"></div>
				</div>
			</div>

			<div class="frame">
				<div class="frame__content">
					<video class="frame-media frame-media_left" src="media/video_optimized.mp4" autoplay loop muted></video>
				</div>
			</div>

			<div class="frame"></div>
			<div class="frame"></div>

			<div class="frame frame_bg">
				<div class="frame__content">
					<div class="frame-media frame-media_right" style="background-image: url(images/5.jpg)"></div>
				</div>
			</div>

			<div class="frame frame_bg">
				<div class="frame__content">
					<video class="frame-media" src="media/video_optimized.mp4" autoplay loop muted></video>
				</div>
			</div>

			<div class="frame"></div>
			<div class="frame"></div>

			<div class="frame">
				<div class="frame__content">The end</div>
			</div>

		</section>
	</div>



<!--HTML-code from my example with low performance:

<div class="block-1">
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Sit in quaerat hic labore quidem odit dicta ea minus alias! Pariatur quos nesciunt doloremque quas quisquam ipsum voluptas, temporibus voluptate id.
</div>

<div class="block-2">
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Sit in quaerat hic labore quidem odit dicta ea minus alias! Pariatur quos nesciunt doloremque quas quisquam ipsum voluptas, temporibus voluptate id.
</div>

<div class="block-3">
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Sit in quaerat hic labore quidem odit dicta ea minus alias! Pariatur quos nesciunt doloremque quas quisquam ipsum voluptas, temporibus voluptate id.
</div>



<div class="containerr">
    <section class="gallery">
        <div class="frame">
            text text text text
        </div>
        <div class="frame">
            text text text text text text text text
        </div>
        <div class="frame">
            text text text text text text text text text text text text text text text text text text text text
        </div>
    </section>
</div>

-->
              
            
!

CSS

              
                * {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}
:root {
	--index: calc(1vw + 1vh);
	--gutter: 30px;
	--side-small: 26;
	--side-big: 36;
	--depth: 4000px;
	--transition: .75s cubic-bezier(.075, .5, 0, 1)
}

/* Скрываем Scrollbar */
body {
	scrollbar-width: none; /* Firefox */
}
body::-webkit-scrollbar { 
	display: none; /* Safari and Chrome */
}

@font-face {
	font-family: raleway_c;
	src: url(../fonts/raleway-v22-cyrillic-300.woff2);
	font-weight: 300;
}
@font-face {
	font-family: raleway_c;
	src: url(../fonts/raleway-v22-cyrillic-100.woff2);
	font-weight: 100;
}
body {
	background-color: #000;
	color: #fff;
	font-size: calc(var(--index) * .8);
	font-family: raleway_c, sans-serif;
	line-height: 1.75;
	height: var(--depth);
	font-weight: 300;
}
.containerr {
	width: 100%;
	height: 100%;
	position: fixed;
	perspective: 1500px;
}
.gallery {
	transform-style: preserve-3d;
	height: 100%;
}
.frame {
	width: 100%;
	height: 100%;
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: var(--transition), opacity .75s ease;
	will-change: transform;
	transform-style: preserve-3d;
}
h1, h2, h3, h4 {
	font-weight: 100;
	text-transform: uppercase;
	width: min-content;
	line-height: 1;
}
.frame h2 {
	text-align: center;
	font-size: calc(var(--index) * 3.3);
}
.frame-media {
	position: relative;
	width: calc(var(--index) * var(--side-small));
	height: calc(var(--index) * var(--side-big));
	background-position: center;
	background-size: cover;
}
.frame-media_left {
	right: calc(var(--side-small) / 2 * var(--index) + var(--gutter));
}
.frame-media_right {
	left: calc(var(--side-small) / 2 * var(--index) + var(--gutter));
}
.frame_bg {
	background-color: rgb(0 0 0 / .87);
}
video.frame-media {
	width: calc(var(--index) * var(--side-big));
	height: calc(var(--index) * var(--side-small));
}
video.frame-media_right {
	left: calc(var(--side-big) / 2 * var(--index) + var(--gutter));
}
video.frame-media_left {
	right: calc(var(--side-big) / 2 * var(--index) + var(--gutter));
}
.text-right > * {
	position: relative;
	left: 18vw;
}
.text-left > * {
	position: relative;
	right: 18vw;
}
.frame h3 {
	font-size: calc(var(--index) * 3);
}
.frame p {
	max-width: 30vw;
	margin-top: 3vh;
}




/* Css-code from my example with low performance:

html, 
body {
    height: 100%;
    line-height: 1;
    font-size: 16px;
    font-family: "Raleway";
    background-color: #1e1b1b;
    color: #fafafa;
    height: var(--depth);
}
:root {
    --index: calc(1vw + 1vh);
    --color-header: #f4efec;
    --color-text: #cdc6c3;
    --transition: 0.75s cubic-bezier(0.2, 0.6, 0, 1);
    --transition-many: 0.2s cubic-bezier(0.2, 0.6, 0, 1);

    --gutter: 30px;
    --side-small: 26;
    --size-big: 36;
    --depth: 4000px; 
}

.block-1 {
  margin-bottom: 50px;
}
.block-2 {
  margin-bottom: 50px;
}
.block-3 {
  margin-bottom: 150px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
:root {
  --index: calc(1vw + 1vh);
  --gutter: 30px;
  --side-small: 26;
  --side-big: 36;
  --depth: 4000px;
  --transition: .75s cubic-bezier(.075, .5, 0, 1)
}


body {
  scrollbar-width: none; 
}
body::-webkit-scrollbar { 
  display: none;
}

@font-face {
  font-family: raleway_c;
  src: url(../fonts/raleway-v22-cyrillic-300.woff2);
  font-weight: 300;
}
@font-face {
  font-family: raleway_c;
  src: url(../fonts/raleway-v22-cyrillic-100.woff2);
  font-weight: 100;
}
body {
  background-color: #000;
  color: #fff;
  font-size: calc(var(--index) * .8);
  font-family: raleway_c, sans-serif;
  line-height: 1.75;
  height: var(--depth);
  font-weight: 300;
}
.containerr {
  width: 100%;
  height: 100vh;
  perspective: 1500px;
}
.gallery {
  transform-style: preserve-3d;
  height: 100%;
}
.frame {
  width: 100%;
  height: 100%;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;

  will-change: transform;

}
h1, h2, h3, h4 {
  font-weight: 100;
  text-transform: uppercase;
  width: min-content;
  line-height: 1;
}
.frame h2 {
  text-align: center;
  font-size: calc(var(--index) * 3.3);
}
.frame-media {
  position: relative;
  width: calc(var(--index) * var(--side-small));
  height: calc(var(--index) * var(--side-big));
  background-position: center;
  background-size: cover;
}
.frame-media_left {
  right: calc(var(--side-small) / 2 * var(--index) + var(--gutter));
}
.frame-media_right {
  left: calc(var(--side-small) / 2 * var(--index) + var(--gutter));
}
.frame_bg {
  background-color: rgb(0 0 0 / .87);
}



.text-right > * {
  position: relative;
  left: 18vw;
}
.text-left > * {
  position: relative;
  right: 18vw;
}
.frame h3 {
  font-size: calc(var(--index) * 3);
}
.frame p {
  max-width: 30vw;
  margin-top: 3vh;
}

}
*/



              
            
!

JS

              
                // 3D Scroll

let zSpacing = -1000,
		lastPos = zSpacing / 5,
		$frames = document.getElementsByClassName('frame'),
		frames = Array.from($frames),
		zVals = []

window.onscroll = function() {

	let top = document.documentElement.scrollTop,
			delta = lastPos - top

	lastPos = top

	frames.forEach(function(n, i) {
		zVals.push((i * zSpacing) + zSpacing)
		zVals[i] += delta * -5.5
		let frame = frames[i],
				transform = `translateZ(${zVals[i]}px)`,
				opacity = zVals[i] < Math.abs(zSpacing) / 1.8 ? 1 : 0
		frame.setAttribute('style', `transform: ${transform}; opacity: ${opacity}`)
	})

}

window.scrollTo(0, 1)





/*The code that your colleagues suggested to me, which really helped.  But it has very low performance and strong lags when scrolling in the opposite direction: from bottom to top:

let frames = gsap.utils.toArray(".frame"),
    overlap = 5,
    time = 0,
    tl = gsap.timeline({
            defaults: {ease: "none", duration: 1},
            scrollTrigger: {
              trigger: ".container",
              start: "top top",
              end: "+=2000",
              pin: true,
              scrub: 0.5
            }
          });
frames.forEach((el, i) => {
  tl.fromTo(el, {opacity: 0, z: -2000}, {opacity: 1}, time)
    .to(el, {z: 2000, duration: 8, ease: "power2.out"}, time)
    .to(el, {opacity: 0, duration: 1}, "-=100%");
  time += 8 - overlap;
})

*/
              
            
!
999px

Console