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 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.
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.
If the stylesheet 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 CSS 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.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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="main-wrapper">
<div class="main-wrapper__title-wrapper">
<div class="main-wrapper__title-content">
<div>
<h1 class="head first">Lorem ipsum</h1>
</div>
<div>
<h1 class="head second">Dolor sit amet</h1>
</div>
</div>
</div>
<!-- <div class="main-wrapper__title-wrapper">
<div class="main-wrapper__title-content">
<div>
<h1>Dolor sit amet</h1>
</div>
</div>
</div> -->
<div class="main-wrapper__panel-wrapper">
<div class="main-wrapper__panel-wrapper-overlay"></div>
<div class="main-wrapper__panel" style="background-image: url('https://dummyimage.com/1920x1080/f1f1f1/454545.png&text=A')"></div>
<div class="main-wrapper__panel" style="background-image: url('https://dummyimage.com/1920x1080/27aa67/ffffff.png&text=B')"></div>
<div class="main-wrapper__panel" style="background-image: url('https://dummyimage.com/1920x1080/f08e29/ffffff.png&text=C')"></div>
<div class="main-wrapper__panel" style="background-image: url('https://dummyimage.com/1920x1080/32c4e4/ffffff.png&text=D')"></div>
<div class="main-wrapper__panel" style="background-image: url('https://dummyimage.com/1920x1080/e031de/ffffff.png&text=E')"></div>
</div>
</div>
<div class="other-content">
<h1>Here's other content</h1>
<h3>This might be some cool text</h3>
<p>Austin fixie banh mi hell of yr sustainable taxidermy fashion axe man braid. Art party sustainable prism synth. Authentic ugh migas yuccie tofu tote bag. Bicycle rights vinyl mlkshk ugh single-origin coffee williamsburg vaporware paleo put a bird on it. Ramps fixie paleo jianbing brunch coloring book intelligentsia blue bottle fashion axe cronut hammock food truck seitan man bun. Humblebrag mumblecore try-hard, irony man bun iPhone mlkshk craft beer. Retro cloud bread 8-bit authentic selvage bitters af ethical tumeric.
Lo-fi meggings sustainable 8-bit. Prism snackwave portland fanny pack. Blue bottle hashtag hammock man bun, tbh paleo XOXO activated charcoal celiac viral narwhal shaman portland crucifix. Meggings narwhal shaman YOLO disrupt, iceland gentrify mlkshk fam banh mi keytar bitters kale chips paleo pickled.
Chillwave selfies bushwick, tacos chartreuse iceland synth +1 swag roof party occupy. Freegan meditation normcore, bushwick kinfolk church-key microdosing cliche lo-fi vexillologist cold-pressed hell of. Green juice humblebrag snackwave godard selvage. Literally pinterest vegan cold-pressed roof party street art master cleanse chicharrones viral leggings jean shorts wayfarers pork belly ethical. Raclette austin meditation try-hard blog bushwick etsy yuccie ugh asymmetrical leggings.</p>
</h3>
body {
background: #ffffff;
margin: 0px,
}
.main-wrapper {
position: relative;
width: 100%;
height: auto;
&__title {
&-wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 99;
}
&-content {
position: sticky;
top: 0;
left: 0;
height: 100vh;
//background: green;
& > div {
width: 100%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
text-align: center;
h1 {
font-size: 7vw;
line-height: 6.5vw;
color: #FFFFFF;
}
}
}
}
&__panel {
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100vh;
&-wrapper {
&-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.2);
z-index: 80;
}
}
}
}
.other-content {
padding: 100px 60px;
p {
font-size: 20px;
line-height:30px;
}
}
.head{
visibility:hidden;
}
console.clear();
gsap.registerPlugin(ScrollTrigger);
var panels_class = ".main-wrapper__panel";
gsap.set('.first', {autoAlpha:1});
var panels = gsap.utils.toArray(panels_class);
panels.forEach((panel, i) => {
// Last element
if ( i == ($(panels_class).length - 1) ) {
console.log(panel);
ScrollTrigger.create({
trigger: panel,
start: "top top",
end: "bottom bottom",
pin: true,
pinSpacing: false,
//markers: true,
});
return;
}
ScrollTrigger.create({
trigger: panel,
start: "top top",
end: "bottom top",
pin: true,
pinSpacing: false,
//markers: true
});
});
var lineAnim = gsap.timeline({
scrollTrigger: {
trigger: panels[2],
start: "top top",
end: "+=50vh", // end after scrolling 50vh beyond the start
// :entering, leaving, backwards, back past the beginning
toggleActions: "play none none reset"
},
})
.to('.first', {autoAlpha:0, duration:0.1})
.to('.second', {autoAlpha:1, duration:0.1})
Also see: Tab Triggers