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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <!-- YOUTUBE CHANNEL 
https://www.youtube.com/channel/UC73Tk5wfEBh67Vm7gM_zaAw?view_as=subscriber
-->

<div class="c-trigger"></div>

<div class="c-spacer"></div>

<div class="c-section js-parallax-section" data-from="0px" data-to="100px">
	<div class="c-section__boxs">
		<div class="c-section__box c-section__box--1 o-anim-ty">1</div>
		<div class="c-section__box c-section__box--2 o-anim-ty">2</div>
		<div class="c-section__box c-section__box--3 o-anim-ty">3</div>
		<div class="c-section__box c-section__box--4 o-anim-ty">4</div>
	</div>
</div>

<div class="c-section js-parallax-section" data-from="-100px" data-to="100px">
	<div class="c-section__image-and-content">
		<div class="c-section__wrapper-image">
			<img class="c-section__image o-anim-ty" src="https://raw.githubusercontent.com/rgldev/sample-images/master/beach-1.jpg">
		</div>
		<div class="c-section__wrapper-content">
			<h3 class="c-section__content">This is awesome!</h3>
		</div>
	</div>
</div>

<div class="c-section js-parallax-section" data-from="100px" data-to="-100px">
	<div class="c-section__scene">
		<div class="c-section__layers">
			<div class="c-section__layer c-section__layer--bg">
				<img class="c-section__layer-image" src="https://raw.githubusercontent.com/rgldev/sample-images/master/parallax_scene_2/1x/Fondo.png">
			</div>
			<div class="c-section__layer c-section__layer--stars o-anim-ty">
				<img class="c-section__layer-image" src="https://raw.githubusercontent.com/rgldev/sample-images/master/parallax_scene_2/1x/Estrellas.png">
			</div>
			<div class="c-section__layer c-section__layer--planet o-anim-ty">
				<img class="c-section__layer-image" src="https://raw.githubusercontent.com/rgldev/sample-images/master/parallax_scene_2/1x/Planeta.png">
			</div>
			<div class="c-section__layer c-section__layer--mountain o-anim-ty">
				<img class="c-section__layer-image" src="https://raw.githubusercontent.com/rgldev/sample-images/master/parallax_scene_2/1x/Montanas.png">
			</div>
			<div class="c-section__layer c-section__layer--floor o-anim-ty">
				<img class="c-section__layer-image" src="https://raw.githubusercontent.com/rgldev/sample-images/master/parallax_scene_2/1x/Suelo.png">
			</div>
		</div>
	</div>
</div>

<div class="c-spacer"></div>

<div class="c-controls">
	<div class="c-controls__button js-debug-button">Debug</div>
</div>
              
            
!

CSS

              
                $white : #FFFFFF;
$black: #0A0F0F;
$bg: #4B597A; //#D0BEA9
$color-a: #00A4B4;
$color-b: #1EC8A8;
$color-c: #90E589;
$color-d: #F9F871;
$color-e: #1B2C49;

// FONTS
$font-a: 'Roboto', sans-serif;

@mixin sm() {
    @media (min-width: 501px) {
        @content;
    }
}
@mixin md() {
    @media (min-width: 1101px) {
        @content;
    }
}

*,
*::before,
*::after{
	box-sizing: border-box;
}


html, 
body{
	
}

body{
	background: $bg;
	font-family: $font-a;
	background-image: linear-gradient(to right, #051937, #004367, #00728f, #00a4a9, #49d5b3);
	
}

.o-anim-ty{
	/*
	* The will-change CSS property provides a way for authors to hint browsers about the kind of changes
	* to be expected on an element, so that the browser can setup appropriate optimizations ahead of time
	* before the element is actually changed.
	*/
	will-change: transform;
	transition: transform 0.1s linear;
}

.c-trigger{
			
	display: none;
	width: 100%;
	height: 1px;
	background-color: rgba($color-c, 1);
	top: 50%;
	right: 0px;
	position: fixed;
	z-index: 2;
	
	.is-debug &{
		display: block;
	}

}

.c-spacer{
	
	display: block;
	width: 100%;
	padding-bottom: 60vh;
	
}

.c-section{
	
	max-width: 100%;
	width: 100%;
	display: block;
	padding: 0px 20px;
	margin: 100px auto;
	position: relative;
	z-index: 3;
	
	@include sm{
		max-width: 100%;
		width: 1140px;
		margin: 200px auto;
		padding: 0px 40px;
		display: flex;
		flex-wrap: wrap;
		align-items: flex-start;
	}
	
	&__boxs{
		
		display: flex;
		width: 100%;
		align-items: center;
		height: 100vh;
		position: relative;
		
		.is-debug &{
			outline: 1px solid $white;
		}
		
		&::before{
			
			content: "";
			display: none;
			width: 100%;
			height: 1px;
			background-color: rgba(orange, 1);
			top: 50%;
			right: 0px;
			position: absolute;
			z-index: 2;
			
			.is-debug &{
				display: block;
			}
			
		}
		
	}
	
	&__box{
		
		width: 80px;
		height: 80px;
		margin: 20px;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 8px;
		color: $black;
		font-size: 20px;
		line-height: 28px;
		box-shadow: 0px 0px 10px 0px rgba($color-e, 0.5);
		position: relative;
		z-index: 3;
		
		&--1{
			background-color: $color-a;
			
			/*
			* Use the same CSS variable as specified in our instance.
			*/
			transform: translateY( calc( ( var(--ty) * 0) ) );
			
		}
		
		&--2{
			background-color: $color-b;
			
			transform: translateY( calc( ( var(--ty) * 0) ) );
			
		}
		
		&--3{
			background-color: $color-c;
			
			transform: translateY( calc( ( var(--ty) * -0.7) ) );
			
		}
		
		&--4{
			background-color: $color-d;
			
			transform: translateY( calc( ( var(--ty) * 1.4) ) );
			
		}
		
	}// END BOX
	
	&__image-and-content{
		
		display: flex;
		width: 100%;
		align-items: center;
		height: 100vh;
		position: relative;
		
		.is-debug &{
			outline: 1px solid $white;
		}
		
		&::before{
			
			content: "";
			display: none;
			width: 100%;
			height: 1px;
			background-color: rgba($white, 0.5);
			top: 50%;
			right: 0px;
			position: absolute;
			z-index: 2;
			
			.is-debug &{
				display: block;
			}
			
		}
		
	}
	
	&__wrapper-image{
		
		display: block;
		width: 80%;
		height: auto;
		position: relative;
		overflow: hidden;
		z-index: 2;
		
		.is-debug &{
			outline: 1px solid orange;
			overflow: visible;
		}
		
		// ASPECT RATIO CSS
		&::before{
			
			content: "";
			display: block;
			padding-bottom: 65%;
			position: relative;
			z-index: 1;
			
		}
		
	}
	
	&__image{
		
		position: absolute;
		top: calc(50% - var(--ty));
		left: 50%;
		width: auto;
		height: calc(100% + 200px);
		transform: translate(-50%, -50%);
		object-fit: cover;
		display: block;

	}
	
	&__wrapper-content{
		
		position: absolute;
		top: 50%;
		right: 10px;
		transform: translateY(-50%);
		z-index: 5;
		display: block;
		width: 300px;
		
	}
	
	&__content{
		
		color: $white;
		font-size: 60px;
		line-height: 72px;
		display: block;
		
	}
	
	&__scene{
		
		display: flex;
		align-items: center;
		width: 100%;
		height: 100vh;
		position: relative;
		overflow: hidden;
		
		.is-debug &{
			outline: 1px solid lightyellow;
			overflow: visible;
		}
		
	}
	
	&__layers{
		
		display: block;
		width: 100%;
		position: relative;
		overflow: hidden;
		
		.is-debug &{
			overflow: visible;
		}
		
	}
	
	&__layer{
		
		$perspective : 1000px;
		$rotateY : -60deg;
		
		position: absolute;
		top: 0px;
		left: 0px;
		width: 100%;
		height: calc(100% + 100px);
		z-index: 1;
		
		.is-debug &{
			outline: 1px solid $black;
		}
		
		&--bg{
			
			position: static;

			.is-debug &{
				transform: perspective(#{$perspective}) translateZ(-1000px) rotateY(#{$rotateY}) translateX(50%);
			}
			
		}
		
		&--stars{
			
			z-index: 2;
			transform: translateY( calc( ( var(--ty) * 0.2) ) );
			
			.is-debug &{
				transform: translateY( calc( ( var(--ty) * 1) ) ) 
					perspective(#{$perspective}) translateZ(-800px) rotateY(#{$rotateY}) translateX(30%);
			}
			
		}
		
		&--planet{
			
			z-index: 3;
			transform: translateY( calc( ( var(--ty) * 0.5) ) );
			
			.is-debug &{
				transform: translateY( calc( ( var(--ty) * 2) ) ) 
					perspective(#{$perspective}) translateZ(-600px) rotateY(#{$rotateY}) translateX(0%);
			}
			
		}
		
		&--mountain{
			
			z-index: 4;
			transform: translateY( calc( ( var(--ty) * 0.8) ) );
			
			.is-debug &{
				transform: translateY( calc( ( var(--ty) * 3) ) ) 
					perspective(#{$perspective}) translateZ(-400px) rotateY(#{$rotateY}) translateX(-25%);
			}
			
		}
		
		&--floor{
			
			z-index: 5;
			transform: translateY( calc( ( var(--ty) * 1) ) );
			
			.is-debug &{
				transform: translateY( calc( ( var(--ty) * 4) ) ) 
					perspective(#{$perspective}) translateZ(-200px) rotateY(#{$rotateY}) translateX(-75%);
			}
			
		}
		
	} // END LAYER
	
	&__layer-image{
		
		width: 100%;
		display: block;
		height: 100%;
		object-fit: cover;
		
	}
	
}


.c-controls{
	
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: auto;
	height: auto;
	z-index: 100;
	display: flex;
	align-items: center;
	
	&__button{
		
		width: auto;
		padding: 10px;
		background-color: $black;
		color: $white;
		cursor: pointer;
		font-size: 20px;
		line-height: 32px;
		transition: all 0.3s ease-in-out;
		margin-right: 20px;
		
		&:hover,
		&.is-active{
			
			background-color: $white;
			color: $black;
			
		}
		
	}
	
}

              
            
!

JS

              
                let parallax_sections = document.querySelectorAll('.js-parallax-section');
for (let parallax_section of parallax_sections) {
	let _from = parallax_section.getAttribute("data-from") || '0px';
	let _to = parallax_section.getAttribute("data-to") || '100px';
	let instance = basicScroll.create({
		elem: parallax_section,
		from: 'top-middle',
		to: 'bottom-middle',
		direct: true,
		props: {
			'--ty': {
				from: _from,
				to: _to,
			}
		}
	})
	instance.start();
}


// DEBUG
var debug_button = document.querySelector('.js-debug-button');
debug_button.onclick = function() {
	debug_button.classList.toggle('is-active');
	document.body.classList.toggle('is-debug');
}
              
            
!
999px

Console