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 id="page">
<header>
<h1 class="page-title">
<div class='revealer'>
<div class='revealer-inner'>Cassie Evans</div>
</div>
<div class='page-title-secondary revealer'>
<div class='revealer-inner'>Keyframers</div>
</div>
</h1>
</header>
<img src="https://images.unsplash.com/photo-1620291699655-d958150a3ff8?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYyMTA4Nzg3Ng&ixlib=rb-1.2.1&q=80&w=1200&h=600" alt="" class="banner">
<h2 class="title revealer">
<div class="revealer-inner">Bestsellers</div>
</h2>
<div class="grid">
<figure>
<figcaption class='revealer'>
<div class='revealer-inner'>This shirt</div>
</figcaption>
<div class="revealer">
<img class='revealer-img' src="https://images.unsplash.com/photo-1526413232644-8a40f03cc03b?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYyMTA4ODI5MA&ixlib=rb-1.2.1&q=80&w=400" alt="" />
</div>
</figure>
<figure>
<figcaption class='revealer'>
<div class='revealer-inner'>And this dress</div>
</figcaption>
<div class="revealer">
<img class='revealer-img' src="https://images.unsplash.com/photo-1602741070475-fc55f644c3f7?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYyMTA4ODI5MA&ixlib=rb-1.2.1&q=80&w=400" alt="" />
</div>
</figure>
<figure>
<figcaption class='revealer'>
<div class='revealer-inner'>Also this blouse</div>
</figcaption>
<div class="revealer">
<img class='revealer-img' src='https://images.unsplash.com/photo-1614282860993-c9f7e9acdf44?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYyMTA4Nzk2OQ&ixlib=rb-1.2.1&q=80&w=400' alt=''>
</div>
</figure>
<figure>
<figcaption class='revealer'>
<div class='revealer-inner'>The table, actually</div>
</figcaption>
<div class="revealer">
<img class='revealer-img' src='https://images.unsplash.com/photo-1614283232994-7f56849e2359?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYyMTA4Nzk2OQ&ixlib=rb-1.2.1&q=80&w=400' alt=''>
</div>
</figure>
<figure>
<figcaption class='revealer'>
<div class='revealer-inner'>Whatever she's holding</div>
</figcaption>
<div class="revealer">
<img class='revealer-img' src='https://images.unsplash.com/photo-1620916927285-21c5218d64a4?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYyMTA4ODI5MA&ixlib=rb-1.2.1&q=80&w=400' alt=''>
</div>
</figure>
<figure>
<figcaption class='revealer'>
<div class='revealer-inner'>Harmless spray</div>
</figcaption>
<div class="revealer">
<img class='revealer-img' src='https://images.unsplash.com/photo-1620916927612-a28afb1dc0f4?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYyMTA4ODk1Nw&ixlib=rb-1.2.1&q=80&w=400' alt=''>
</div>
</figure>
<span class="spacer1"></span>
<span class="spacer2"></span>
<span class="spacer3"></span>
<span class="spacer4"></span>
</div>
<svg id="stroke-svg" preserveAspectRatio="xMidYMid slice" fill-rule="evenodd" stroke-miterlimit="1.5" clip-rule="evenodd" viewBox="0 0 2132 5344">
<defs>
<mask id="stroke-mask">
<path id="mask-stroke" fill="none" stroke="white" stroke-width="5" d="M324.813-52.135C204.651 65.523 458.362 173.469 601.765 189.285c169.887 18.737 410.22-29.224 520.966-82.617 100.731-48.564 154.809-138.521 101.624-165.772-55.127-28.247-560.763 155.569-415.777 300.554 49.997 49.998 502.244 145.465 784.213 38.725 155.512-58.87 188.43-160.067 172.708-189.71-27.518-51.882-247.239 28.961-305.985 65.473-276.859 172.073-515.191 899.522-201.638 1338.54 206.052 288.502 827.828 487.908 785.773 164.706-17.293-132.902-272.903-149.223-367.935-88.64-113.522 72.37-335.863 193.745-231.163 504.727 88.882 264 678.637 273.92 544.444 558.087-147.028 311.346-586.597 149.888-757.298 124.559-379.379-56.295-803.402-136.829-955.247 297.618-59.843 171.216-44.961 489.493 70.837 631.153 162.443 198.723 459.583-129.982 369.648-294.59-96.415-176.467-322.65 22.711-396.282 105.313-97.708 109.612-166.931 399.956-39.123 502.579 267.219 214.564 622.086-28.76 831.909 21.963 561.219 135.67 235.391 679.206 457.463 917.719 221.323 237.708 654.322-95.359 407.084-266.334-358.912-248.2-527.841 403.197-687.761 495.191-241.38 138.854-374.262-119.763-602.689-142.606-73.378-7.337-157.751-.818-224.685 31.794-15.142 7.378-52.177 37.97-69.586 37.97" />
</mask>
</defs>
<path id="stroke" stroke="grey" mask="url(#stroke-mask)" stroke-dasharray="20" stroke-dashoffset="var(--dashOffset)" fill="none" stroke-width="5" d="M324.813-52.135C204.651 65.523 458.362 173.469 601.765 189.285c169.887 18.737 410.22-29.224 520.966-82.617 100.731-48.564 154.809-138.521 101.624-165.772-55.127-28.247-560.763 155.569-415.777 300.554 49.997 49.998 502.244 145.465 784.213 38.725 155.512-58.87 188.43-160.067 172.708-189.71-27.518-51.882-247.239 28.961-305.985 65.473-276.859 172.073-515.191 899.522-201.638 1338.54 206.052 288.502 827.828 487.908 785.773 164.706-17.293-132.902-272.903-149.223-367.935-88.64-113.522 72.37-335.863 193.745-231.163 504.727 88.882 264 678.637 273.92 544.444 558.087-147.028 311.346-586.597 149.888-757.298 124.559-379.379-56.295-803.402-136.829-955.247 297.618-59.843 171.216-44.961 489.493 70.837 631.153 162.443 198.723 459.583-129.982 369.648-294.59-96.415-176.467-322.65 22.711-396.282 105.313-97.708 109.612-166.931 399.956-39.123 502.579 267.219 214.564 622.086-28.76 831.909 21.963 561.219 135.67 235.391 679.206 457.463 917.719 221.323 237.708 654.322-95.359 407.084-266.334-358.912-248.2-527.841 403.197-687.761 495.191-241.38 138.854-374.262-119.763-602.689-142.606-73.378-7.337-157.751-.818-224.685 31.794-15.142 7.378-52.177 37.97-69.586 37.97" />
</svg>
</div>
<a href="https://youtu.be/sFJa1ThZReA" target="_blank" data-keyframers-credit style="color: #000"></a>
<script src="https://codepen.io/shshaw/pen/QmZYMG.js"></script>
@import url("https://fonts.googleapis.com/css2?family=Arimo:wght@500&family=Playfair+Display&display=swap");
*,
*::before,
*::after {
box-sizing: border-box;
position: relative;
}
:root {
--duration: 2s;
--delay: 0s;
--easing: cubic-bezier(0.25, 0, 0.25, 1);
}
html {
font-family: "Playfair Display", serif;
background: #e9e5e2;
height: 100%;
}
body {
min-height: 100%;
padding: 0;
margin: 0;
padding-bottom: 9rem;
animation: fade-in 0.5s linear 0.5s both;
@keyframes fade-in {
from {
opacity: 0;
}
}
}
img {
max-width: 100%;
display: block;
filter: grayscale(10%) sepia(10%);
}
#page {
position: relative;
padding-top: 2.5rem;
}
.page-title {
font-size: 90px;
font-family: "Arimo", sans-serif;
font-weight: 500;
line-height: 0.8;
margin: 0 1rem 1.5rem 1rem;
letter-spacing: -0.05em;
> .page-title-secondary {
padding-bottom: 1rem;
opacity: 0.3;
--delay: calc(var(--duration) / 4);
}
}
.revealer {
overflow: hidden;
// padding: .25em 0;
// margin: -.4em 0;
// &[data-visible] > .revealer-inner {
// animation-play-state: running;
// animation-delay: var(--delay, 0s);
// }
}
// .revealer-inner {
// animation: reveal 1s var(--easing) both;
// animation-play-state: paused;
// }
// @keyframes reveal {
// from {
// transform: translateY(120%);
// }
// to {
// transform: none;
// }
// }
.banner {
width: 100%;
max-height: 500px;
object-fit: cover;
animation: banner var(--duration) calc(var(--duration) / 2)
cubic-bezier(0.1, 0, 0.1, 1) both;
@keyframes banner {
from {
clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
}
to {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
}
}
.title {
margin: 3rem 1rem;
font-size: 2rem;
}
.grid {
display: grid;
grid-template-columns: 1.5fr 1fr 1.5fr;
margin: 0 1rem;
grid-gap: 2rem 0;
.spacer1 {
grid-row: 1;
grid-column: 3;
}
.spacer2 {
grid-row: 2;
grid-column: 1;
}
.spacer3 {
grid-row: 3;
grid-column: 3;
}
.spacer4 {
grid-row: 4;
grid-column: 1;
}
figure {
position: relative;
margin: 0;
overflow: hidden;
}
img {
width: 100%;
}
figcaption {
font-family: sans-serif;
font-weight: semi-bold;
text-align: center;
margin-bottom: 0.5rem;
}
}
#stroke-svg {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: -1;
}
#stroke {
--dashOffest: 0;
}
gsap.from("#mask-stroke", {
drawSVG: "0%",
scrollTrigger: {
trigger: "#page",
start: "-7% top",
end: "bottom+=20% bottom",
scrub: 1
}
});
gsap.from("#stroke", {
"--dashOffset": 1000,
delay: 1,
scrollTrigger: {
trigger: "#page",
start: "-5% top",
end: "bottom+=20% bottom",
scrub: 1
}
});
let text = gsap.utils.toArray(".revealer-inner");
text.forEach((el, i) => {
gsap.from(el, {
yPercent: 120,
duration: 1,
delay: el.classList.contains("page-title-secondary") ? 2 : 1,
scrollTrigger: {
trigger: el,
start: "top center",
end: "bottom top",
toggleActions: "restart pause resume reset"
}
});
});
let images = gsap.utils.toArray(".revealer-img");
images.forEach((el) => {
gsap.from(el, {
opacity: 0,
yPercent: 10,
scale: 1.2,
duration: 2,
scrollTrigger: {
trigger: el,
start: "top bottom",
end: "bottom top",
//markers: true,
toggleActions: "restart pause resume pause"
}
});
});
// const observer = new window.IntersectionObserver(([entry]) => {
// if (entry.isIntersecting) {
// console.log(entry)
// entry.target.dataset.visible = true;
// } else {
// delete entry.target.dataset.visible;
// }
// }, {
// root: null,
// threshold: 0,
// })
// document
// .querySelectorAll('.revealer')
// .forEach(el => {
// if (elementInViewport(el)) {
// el.dataset.visible = true;
// }
// observer.observe(el);
// });
// function elementInViewport(el) {
// var rect = el.getBoundingClientRect();
// return (
// rect.top >= 0 &&
// rect.left >= 0 &&
// rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
// rect.right <= (window.innerWidth || document.documentElement.clientWidth)
// );
// }
Also see: Tab Triggers