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.
<span class="keyhole" aria-hidden="true"></span>
<span class="arrow" aria-hidden="true">
<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="-5 -5 30 30">
<path d="M 0 10 H 20 L 10 0 M 20 10 L 10 20" stroke-width="4" stroke-linecap="square" stroke-linejoin="round"></path>
</svg>
</span>
<main class="main">
<section class="section section--primary">
<div class="section__content">
<figure>
<img src="https://picsum.photos/id/315/1600/1600" width="1600" height="1600"/>
</figure>
<h1>At vero eos et accusamus.</h1>
<p>Cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia. Corrupti quos dolores et quas molestias excepturi sint occaecati. Ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>
<p>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam. Et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque.</p>
</div>
</section>
<section class="section section--secondary">
<div class="section__content">
<p>Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat. <strong> At vero eos et accusamus.</strong> <em> Nisi ut aliquid ex ea commodi consequatur?</em> Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam.</p>
<h2>At vero eos et accusamus.</h2>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem. Accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat.</p>
<ol>
<li>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam.</li><li>Et harum quidem rerum facilis est et expedita distinctio.</li><li>Architecto beatae vitae dicta sunt explicabo.</li>
</ol>
<h3>Nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam.</h3>
<p>Eaque ipsa quae ab illo inventore veritatis et quasi. Nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam. Duis aute irure dolor in reprehenderit in voluptate velit.</p>
<ul>
<li>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam.</li><li>At vero eos et accusamus.</li><li>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit.</li>
</ul>
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa. Laboris nisi ut aliquip ex ea commodo consequat. Animi, id est laborum et dolorum fuga. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.</p>
<p>Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Sed ut perspiciatis unde omnis iste natus error sit voluptatem.</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit. Eaque ipsa quae ab illo inventore veritatis et quasi. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam.</p>
<p>Nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam. Facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo.</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco. At vero eos et accusamus. Sed ut perspiciatis unde omnis iste natus error sit voluptatem. Architecto beatae vitae dicta sunt explicabo. Et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ut enim ad minim veniam, quis nostrud exercitation ullamco. Ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>
<p>Fugiat quo voluptas nulla pariatur? Et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque. Et harum quidem rerum facilis est et expedita distinctio. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>
<p>Corrupti quos dolores et quas molestias excepturi sint occaecati. Animi, id est laborum et dolorum fuga. Excepteur sint occaecat cupidatat non proident, sunt in culpa. Corrupti quos dolores et quas molestias excepturi sint occaecati.</p>
<p>Totam rem aperiam. At vero eos et accusamus. Eaque ipsa quae ab illo inventore veritatis et quasi. Excepteur sint occaecat cupidatat non proident, sunt in culpa. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam.</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco. Architecto beatae vitae dicta sunt explicabo. Nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam.</p>
</div>
</section>
<section class="section section--tertiary">
<div class="section__content">
<h2>Qui officia deserunt mollit anim id est laborum.</h2>
<p>Et harum quidem rerum facilis est et expedita distinctio. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit. Et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque.</p>
<p>Eaque ipsa quae ab illo inventore veritatis et quasi. <strong> Nihil molestiae consequatur, vel illum qui dolorem eum.</strong> <em> Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam.</em> Et harum quidem rerum facilis est et expedita distinctio.</p>
</div>
</section>
</main>
$primary: #ffeaa7;
$secondary: #a29bfe;
$tertiary: #fab1a0;
$text: #2d3436;
$contrast: #dfe6e9;
$accent: #fdcb6e;
$multiplier: 1.3;
.keyhole {
position: fixed;
inset: 0;
pointer-events: none;
background: $accent;
clip-path: polygon(0% 0%, 0% 100%, 0 100%, 0 0, 100% 0, 100% 100%, 0 100%, 0 100%, 100% 100%, 100% 0%);
z-index: 1;
}
.arrow {
position: absolute;
top: 72.5vh;
left: 50%;
z-index: 2;
animation: float 1s ease-in-out infinite alternate both;
svg {
transform: rotate(90deg);
stroke: $text;
width: 2rem;
margin-left: -1rem;
height: auto;
}
}
html {
font-size: 100%;
}
body {
font: 400 1.2rem/1.45 "Mulish", sans-serif;
background: $contrast;
color: $text;
}
h1, h2, h3, h4, h5 {
font-family: "DM Serif Text", serif;
line-height: 1;
font-weight: 400;
}
@for $i from 1 through 5 {
h#{$i} {
font-size: #{$multiplier * (5 - $i)}rem;
}
}
.section {
&--primary {
background: $primary;
figure {
position: relative;
left: 50%;
width: 100vw;
transform: translateX(-50%);
margin: 0 0 1em 0;
img {
width: 100%;
object-fit: cover;
min-height: 100vh;
}
}
.section__content {
padding-top: 0;
}
}
&--secondary {
background: $secondary;
}
&--tertiary {
background: $tertiary;
}
&__content {
max-width: 900px;
margin: 0 auto;
padding: 80px 40px;
}
}
@keyframes float {
from {
transform: translateY(-50%);
}
to {
transform: translateY(50%);
}
}
(function () {
const isAnimationOk = window.matchMedia('(prefers-reduced-motion: no-preference)').matches;
// Cnahge to false to make the animations play when the section's in viewport
const scrub = true;
if(isAnimationOk) {
setupAnimations();
}
function setupAnimations() {
gsap.from(".keyhole", {
"clip-path": "polygon(0% 0%, 0% 100%, 25% 100%, 25% 25%, 75% 25%, 75% 75%, 25% 75%, 25% 100%, 100% 100%, 100% 0%)",
scrollTrigger: {
trigger: ".section--primary",
start: "top top", // when the top of the trigger hits the top of the viewport
end: "bottom bottom", // bottom of the trigger hits the bottom of the vp
scrub: scrub,
markers: false
}
});
gsap.to(".arrow", {
opacity: 0,
scrollTrigger: {
trigger: ".section--primary",
start: "top top", // when the top of the trigger hits the top of the viewport
end: "+=200", // scroll 150px down
scrub: scrub
}
});
}
}());
Also see: Tab Triggers