HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<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>
-->
* {
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;
}
}
*/
// 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;
})
*/
Also see: Tab Triggers