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>
<div class="container">
<div class="panel blue">1500px</div>
<div class="panel orange">
<h1>height is based on content</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed ligula arcu. Pellentesque rutrum, eros a tempus convallis, nisl nisi cursus tellus, id vehicula enim felis sed tellus. Curabitur at urna vitae urna convallis semper tincidunt et mauris. Ut ac dui hendrerit, viverra sapien ac, tincidunt libero. Fusce ac eleifend tellus. Integer ut purus at odio ornare tristique id sed ex. Ut luctus enim a libero aliquet, quis rhoncus lacus interdum. Sed ornare cursus augue, eu auctor enim.
Vestibulum erat urna, cursus a eros eu, dignissim ultrices leo. Donec finibus mauris at orci cursus, sed sollicitudin purus vestibulum. Donec lacinia auctor nunc quis interdum. Sed lobortis eros nec ultricies sodales. Aenean vitae sodales lectus. Aliquam erat volutpat. In convallis tempus tempor.
In vulputate risus ut arcu faucibus, vel rhoncus orci tempus. Mauris porta, arcu vel vulputate tempus, neque dolor finibus orci, vitae luctus ante sapien in lectus. Pellentesque viverra blandit ipsum eget ultrices. Sed consectetur porta blandit. Nullam commodo leo vel scelerisque iaculis. Nunc ultricies ante tincidunt placerat aliquet. Vivamus pretium tellus ac magna lacinia ornare. Nam aliquet purus id massa vestibulum, ut auctor augue consectetur. Aliquam erat volutpat. Curabitur fermentum malesuada justo, at eleifend nulla condimentum at.
In urna metus, sodales at blandit sed, eleifend at orci. Donec tempor in purus a finibus. Donec nec metus cursus neque venenatis dapibus maximus at orci. Ut id metus porttitor, dapibus erat et, lobortis dolor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Duis vulputate congue urna at viverra. Phasellus finibus porttitor dui et lobortis. In finibus ligula vitae congue dapibus. Vivamus malesuada tellus risus, ac hendrerit leo pretium eu.
Cras lobortis ligula tempor sagittis semper. In cursus rhoncus rhoncus. Cras id felis quis ex ullamcorper cursus a sollicitudin tellus. Mauris nec volutpat magna. Aliquam lobortis dolor consectetur condimentum euismod. Cras tincidunt lectus dictum ultricies gravida. Integer sit amet tellus aliquet sem tempus commodo vel at mauris. Aenean at feugiat nisi. Aenean scelerisque nisl vitae lacinia dignissim.</p>
</div>
<div class="panel yellow">1600px</div>
<div class="panel video">
<div class="box"></div>
</div>
<div class="panel purple">100vh</div>
<div class="panel red">100vh</div>
<div class="panel purple">100vh</div>
</div>
</div>
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
}
.container {
height: 100%;
width: 100%;
position: relative;
}
.logger {
position: fixed;
top: 40px;
right: 0;
width: 120px;
background: rgba(0, 0, 0, 1);
color: white;
border: 2px solid #af4261;
padding: 10px;
font-size: 12px;
}
.panel {
border: 1px dashed black;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
color: red;
background: linear-gradient(0deg, #f3ec78, #af4261);
font-size: 3rem;
padding: 3rem;
}
.blue {
height: 1500px;
background: linear-gradient(0deg, #020c56, blue);
}
.orange {
background: linear-gradient(0deg, #fa6800, orange);
display: flex;
flex-direction: column;
}
.yellow {
height: 1600px;
background: linear-gradient(0deg, #f3ec78, yellow);
}
.purple {
height: 100vh;
font-size: 20px;
display: flex;
flex-direction: column;
justify-content: center;
}
.red {
height: 100vh;
background: linear-gradient(0deg, #f3ec78, red);
font-size: 20px;
color: white;
display: flex;
flex-direction: column;
justify-content: center;
}
.lightBlue {
height: "100%";
background: linear-gradient(0deg, #00b4db, rgb(9, 103, 134));
display: flex;
flex-direction: column;
position: relative;
}
.lightGreen {
height: "100%";
background: linear-gradient(0deg, #086202, rgb(153, 231, 120));
display: flex;
flex-direction: column;
/* position: relative; */
}
.line {
width: 100%;
max-width: 800px;
height: 8px;
margin: 0 0 10px 0;
position: relative;
display: inline-block;
background-color: rgba(255, 255, 255, 1);
}
.spacer {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
font-size: 20px;
height: 1000px;
background-color: beige;
opacity: 0.5;
}
.video {
background-color: white;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.box {
width: 200px;
height: 200px;
background-color: red;
}
const panels = gsap.utils.toArray(".panel");
panels.forEach((panel, i) => {
if (i > 0) {
gsap.set(panel, {
y: -window.innerHeight,
zIndex: -i
});
// handle the video ons seperately
if (panel.classList.contains("video")) {
gsap.to(".box", {
rotation: 360,
scrollTrigger: {
trigger: panel,
scrub: true,
end: `top+=${window.innerHeight}`,
pin: true,
pinSpacing: false,
markers: true
}
});
} else {
ScrollTrigger.create({
trigger: panel,
end: `top+=${window.innerHeight}`,
pin: true,
pinSpacing: false,
markers: {
startColor: "grey",
endColor: "darkGrey",
fontSize: "20px"
},
scrub: 1
});
}
}
});
// scrolltriggers must be created in the order they appear on the page
// ScrollTrigger.sort();
Also see: Tab Triggers