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 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.
<!--
Resource SVG for Parallax
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 240" style="position:absolute;top:0;left:0;width:0;height:0;overflow:hidden;" focusable="false" aria-hidden="true">
<!-- show content using white mask fill -->
<style>mask { fill: white; }</style>
<!-- masks -->
<mask id="m1" >
<path d="M480 215.9h-3.9v3.3l-18-.7V240H480zM405 240l-.6-85.5-4.4-3.6-6.9-.7h-6.2v.5l-17.7-.5v-1h-1.3v1l-.7-.1-.6 1-4.3.1v-1l-.7-.1v-1.3l-.5-.5h-1v.8l-1.5-.1v.7l-.6-.1v-1.3l-1.3.3v1.2l-1.8-.2-3.1-.1-1.8-1.5-1.9 1.2v.7l-6.3-.1-.8-.2.4 90.4zm-181.5 0v-86.5l1-1.2h.4v-9.5h2.6v-4.5l.7-.4v-5.1l3.9-1.1h.9v-1.2h-.7v-1.3l2.8-1v-2.7l1.3-.9h5.1v2.5l.8.1 1.3.9v3.7l3.2-.2v2l.3 3.4.4.2v4.6l2.3.1.3 6.7 1.1.2v2.6l.9.1v51.1l6.3.3.7.2v10l2.3.1v6.6l.7.1v10.3h.4v9.8zm-128.8 0l1.8-1.2v-1.5h.6v-.7l2.3-1.5h.4v-2.9l.8-.9h3.6v3.6h3l8.3.4v-25.4l2.4-1.3v-6.1l1.5-.7 3.4-.9v-4l.4-.4.4-3.1h2.6v-1.5l1.1-.5h1.9v-.5h.6v-2.6h1v-.7h7.8v3l-.5.5v.7l.5.1.5.7 2.2-.2v-.3h.6v.4l.5-.1.5-.4h.3v3.7l.7.1v5.8l4.6-.3.5 15.1 1.1.2.3 23.4zM0 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 4.4-4.4.4v-.8l-1.4-1.5-2.4 1-.4 2-1.3-.7-1.4-.4-1.2-1.6v-.8l-1.2-.3-.4-1.2-3.7.1v4.2l-1.2 1.1-1.1-.2-1.1.2-.3-3.3-2.9-.1v2.8l-1.5.6v-1.7l-1.1-.1v-4.7l-1-.2v.5l-.6 5.3-1.4.3-.7-.5-1-.9-1.6.3v-1l-1.5.3-3.2 1.3h-1.1v-2l-1.4-1.1-1.3 1.1v3.9l-.6.4-.9-.2-.9-1.3-1.3-1.4v-2.1l-.6-.8-1 1.5-.4 4.7-1.7.1-1.9-.4-2-.4-1.1-1.3-.8-.1-3.9-.2-2.3.1-.9 2.2v1.5l-3.6.6-1.4.6-1.6 1.9-1 1.6-2.3.9-.5 2h-1.1v-2.8l-2.1-1.3-3.3-.1-1.6.8-3 1.2v2.6l-2 .1-2.6.1-2.5-.6-12.9-.9-2.2.1-1-1.3-.7-2.8v-1.3l-2.8.1v5.1l-16.3-.6-14-.2H3.8l-.7-.7-.7-1.7-1-1-1.4-.1V240h480z"/>
</mask>
<mask id="m8">
<path d="M0 101.4l43.5-2.2h184.4l1.3-.6.5-1h.8l1 1.1 3.4.1 19.9-.3 1.5-.9h.6l1.6 1.2 70.3-.2 43.4.2.6-1.6v1.1l.8.5h81.7l.4-1h5.2l.4 1 18.7-.5V240H0z"/>
</mask>
<!-- parallax parts + background image -->
<svg id="bg">
<image width="480" height="240" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/68939/ny.jpg" />
</svg>
<svg id="p8"><use mask="url(#m8)" xlink:href="#bg" /></svg>
<svg id="p7"><use mask="url(#m7)" xlink:href="#bg" /></svg>
<svg id="p6"><use mask="url(#m6)" xlink:href="#bg" /></svg>
<svg id="p5"><use mask="url(#m5)" xlink:href="#bg" /></svg>
<svg id="p4"><use mask="url(#m4)" xlink:href="#bg" /></svg>
<svg id="p3"><use mask="url(#m3)" xlink:href="#bg" /></svg>
<svg id="p2"><use mask="url(#m2)" xlink:href="#bg" /></svg>
<svg id="p1"><use mask="url(#m1)" xlink:href="#bg" /></svg>
</svg>
<div class="page">
<header>
<!--
The Parallax
Note! unlike DOM elements SVG's will cause repaints even if
animating transforms only. To better animation performance
we wrap each parallax part in a div and animate that
-->
<div class="parallax">
<div class="bg"><svg viewBox="0 0 480 240"><use xlink:href="#bg" /></svg></div>
<div class="p8"><svg viewBox="0 0 480 240"><use xlink:href="#p8" /></svg></div>
<div class="p7"><svg viewBox="0 0 480 240"><use xlink:href="#p7" /></svg></div>
<div class="p6"><svg viewBox="0 0 480 240"><use xlink:href="#p6" /></svg></div>
<div class="p5"><svg viewBox="0 0 480 240"><use xlink:href="#p5" /></svg></div>
<div class="p4"><svg viewBox="0 0 480 240"><use xlink:href="#p4" /></svg></div>
<div class="p3"><svg viewBox="0 0 480 240"><use xlink:href="#p3" /></svg></div>
<div class="p2"><svg viewBox="0 0 480 240"><use xlink:href="#p2" /></svg></div>
<div class="p1"><svg viewBox="0 0 480 240"><use xlink:href="#p1" /></svg></div>
</div>
</header>
<main>
<h1>
<svg class="logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129.3 145.3">
<path d="M128.8 122.6c-2 2.4-14 14.3-24.3 21.4-1.8-24.8-13.7-40.7-33.2-54.3a336 336 0 0 0-.2 33c.4 7 3.8 11.2 9.3 15.7-7.2 1.6-28 1.3-35-1 .7-.5 9.5-5.4 10.3-21.3.5-11.4.6-19.8.2-33.7l-.9-3.6c-9.5-7-17.7-14.1-28.4-25.6 9.8 25.7-2.6 57.8-4 69.6-.5 4-1.8 12-1.3 20.3-3.1-1.9-15.4-10-21.3-17.6C17.1 96 29.6 67.3 2.7 41c5-7.6 12.5-14.4 18.6-17.3a80.4 80.4 0 0 0 30 38.9C43.7 34.4 33.9 25 27.7 21.9c4.1-9.5 17.5-19.4 24.6-22a43.5 43.5 0 0 0-.3 28.8c3.3 11.4 8.4 25.2 14 35.6C69.2 59 79.9 36.7 82.8 27a53.9 53.9 0 0 0 1.6-24.8A77.5 77.5 0 0 1 107 24c-6.5 1.4-9.6 4.7-13.4 11.4-4 6.8-14 32.5-19.6 43.6 5.9 5 16.1 11.4 24.3 21.2-9-35.2.2-62 12-70 5.4 1.7 12.4 6.2 17.5 11.5-19.1 8-17.9 32.4-18 34.2-.8 14 4.8 38.8 15.4 44.9a34 34 0 0 0 3.7 2c-2 2.4-14 14.2-24.3 21.3"/>
</svg>
New York
</h1>
<a class="no-iframe" href="https://codepen.io/jakob-e/debug/ELqeRM/" target="_blank">Open in debug mode</a>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum quisquam odio consequuntur aliquam nobis eius voluptatem. Nam eum cumque ullam, quae tenetur sed repellendus non accusamus voluptatum quisquam corporis qui?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum quisquam odio consequuntur aliquam nobis eius voluptatem. Nam eum cumque ullam, quae tenetur sed repellendus non accusamus voluptatum quisquam corporis qui?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum quisquam odio consequuntur aliquam nobis eius voluptatem. Nam eum cumque ullam, quae tenetur sed repellendus non accusamus voluptatum quisquam corporis qui?</p>
<svg class="separator" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000">
<path d="M488 13.6c-13.8 7.6-14.4 10.6-14.4 76 0 37.5-.8 58.4-2 58.4-7.5 0-28.4 28.2-28.4 38.3 0 2.2-4.3 8.7-9.3 14.8a105.4 105.4 0 0 0-23.2 46c-1 6.2-2 28.3-2 49.2v38.3H403c-8.3 0-18.8 6.5-23.1 14.4-3.4 6.5-3.6 17.4-3.6 223.4V789h-22c-25.1 0-33.2 2.9-39.3 14.4-3.3 6.3-3.7 13.2-3.7 82.6 0 83.8.4 86.2 12.6 93.7 8.5 5.1 19 5.1 27.6 0 12-7.3 12.6-11.3 12.6-78v-60H386c25.2 0 33.3-2.8 39.4-14.3 3.4-6.5 3.6-17.5 3.6-223.4V387.3h5.7c8.3 0 18.9-6.5 23.1-14.4 3.3-6 3.7-12.3 3.7-62.5 0-52.5.2-56.2 4.2-64.7 6.5-13.4 17.5-19.7 34.3-19.7s27.8 6.3 34.3 19.7c4 8.5 4.3 12.2 4.3 64.7 0 50.2.4 56.4 3.6 62.5 4.3 8 14.8 14.4 23.1 14.4h5.7V604c0 206 .2 216.9 3.7 223.4 6 11.6 14.2 14.4 39.3 14.4h22v59.8c0 66.8.5 70.8 12.5 78.2 8.5 5 19 5 27.6 0 12.2-7.6 12.6-10 12.6-93.8 0-69.4-.4-76.3-3.7-82.5-6-11.6-14.2-14.4-39.3-14.4h-22V572.4c0-206-.1-216.9-3.6-223.4a29.6 29.6 0 0 0-23.1-14.4h-5.7v-38.3c0-21-1-43.2-2-49.1a111 111 0 0 0-23.1-46c-5.1-6.2-9.4-12.5-9.4-14.3 0-10.5-20.9-39-28.4-39-1.2 0-2-20.8-2-58.4 0-52.5-.4-59-3.7-65A29.7 29.7 0 0 0 500 10c-2.8 0-8.3 1.6-12 3.6zM715.3 338.3c-7.8 4-14.4 14.8-14.4 22.7s6.7 18.7 14.4 22.7c5.4 2.8 11.3 3.7 28.6 3.7h21.9v287c0 316.1-.8 297.2 12.6 305.4 8.5 5 19 5 27.5 0 13.2-8.2 12.6 4.2 12.6-240.5V517.2h77.1v225.2c0 244.7-.4 233.9 11.2 243 7.7 6.1 22.7 6.1 30.4 0 11.8-9.1 11.2 3 11.2-258.6 0-229.7-.2-241.5-3.7-248-7.3-13.5-11-14.4-71.8-14.4h-54.4v-54.3c0-48.7-.4-55-3.6-61.1-7-12.8-12.8-14.4-55.2-14.4-32.5 0-38.6.4-44.5 3.7zM195.9 403.2c-13.6 7.3-14.4 11-14.4 71.8v54.4H127c-60.8 0-64.5.8-71.8 14.4-3.5 6.5-3.7 17.2-3.7 212.4 0 226.2-.6 215.4 12.6 223.5 8.6 5.1 19.1 5.1 27.6 0 13.2-8 12.6 1 12.6-207.9V582.1h77.1v189.7c0 209-.6 199.8 12.6 208 13.4 8 31.4 2.6 37.3-11.2 2.4-5.9 2.9-44.6 2.9-261.7V452.3h21.9c17.2 0 23-.8 28.6-3.7 7.7-4 14.4-14.8 14.4-22.7s-6.7-18.7-14.4-22.7c-6-3.3-12-3.7-44.5-3.7s-38.5.4-44.4 3.7z"/>
</svg>
<h2>8,500,000 Souls</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum quisquam odio consequuntur aliquam nobis eius voluptatem. Nam eum cumque ullam, quae tenetur sed repellendus non accusamus voluptatum quisquam corporis qui?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum quisquam odio consequuntur aliquam nobis eius voluptatem. Nam eum cumque ullam, quae tenetur sed repellendus non accusamus voluptatum quisquam corporis qui?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum quisquam odio consequuntur aliquam nobis eius voluptatem. Nam eum cumque ullam, quae tenetur sed repellendus non accusamus voluptatum quisquam corporis qui?</p>
<svg class="separator" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000">
<path d="M488 13.6c-13.8 7.6-14.4 10.6-14.4 76 0 37.5-.8 58.4-2 58.4-7.5 0-28.4 28.2-28.4 38.3 0 2.2-4.3 8.7-9.3 14.8a105.4 105.4 0 0 0-23.2 46c-1 6.2-2 28.3-2 49.2v38.3H403c-8.3 0-18.8 6.5-23.1 14.4-3.4 6.5-3.6 17.4-3.6 223.4V789h-22c-25.1 0-33.2 2.9-39.3 14.4-3.3 6.3-3.7 13.2-3.7 82.6 0 83.8.4 86.2 12.6 93.7 8.5 5.1 19 5.1 27.6 0 12-7.3 12.6-11.3 12.6-78v-60H386c25.2 0 33.3-2.8 39.4-14.3 3.4-6.5 3.6-17.5 3.6-223.4V387.3h5.7c8.3 0 18.9-6.5 23.1-14.4 3.3-6 3.7-12.3 3.7-62.5 0-52.5.2-56.2 4.2-64.7 6.5-13.4 17.5-19.7 34.3-19.7s27.8 6.3 34.3 19.7c4 8.5 4.3 12.2 4.3 64.7 0 50.2.4 56.4 3.6 62.5 4.3 8 14.8 14.4 23.1 14.4h5.7V604c0 206 .2 216.9 3.7 223.4 6 11.6 14.2 14.4 39.3 14.4h22v59.8c0 66.8.5 70.8 12.5 78.2 8.5 5 19 5 27.6 0 12.2-7.6 12.6-10 12.6-93.8 0-69.4-.4-76.3-3.7-82.5-6-11.6-14.2-14.4-39.3-14.4h-22V572.4c0-206-.1-216.9-3.6-223.4a29.6 29.6 0 0 0-23.1-14.4h-5.7v-38.3c0-21-1-43.2-2-49.1a111 111 0 0 0-23.1-46c-5.1-6.2-9.4-12.5-9.4-14.3 0-10.5-20.9-39-28.4-39-1.2 0-2-20.8-2-58.4 0-52.5-.4-59-3.7-65A29.7 29.7 0 0 0 500 10c-2.8 0-8.3 1.6-12 3.6zM715.3 338.3c-7.8 4-14.4 14.8-14.4 22.7s6.7 18.7 14.4 22.7c5.4 2.8 11.3 3.7 28.6 3.7h21.9v287c0 316.1-.8 297.2 12.6 305.4 8.5 5 19 5 27.5 0 13.2-8.2 12.6 4.2 12.6-240.5V517.2h77.1v225.2c0 244.7-.4 233.9 11.2 243 7.7 6.1 22.7 6.1 30.4 0 11.8-9.1 11.2 3 11.2-258.6 0-229.7-.2-241.5-3.7-248-7.3-13.5-11-14.4-71.8-14.4h-54.4v-54.3c0-48.7-.4-55-3.6-61.1-7-12.8-12.8-14.4-55.2-14.4-32.5 0-38.6.4-44.5 3.7zM195.9 403.2c-13.6 7.3-14.4 11-14.4 71.8v54.4H127c-60.8 0-64.5.8-71.8 14.4-3.5 6.5-3.7 17.2-3.7 212.4 0 226.2-.6 215.4 12.6 223.5 8.6 5.1 19.1 5.1 27.6 0 13.2-8 12.6 1 12.6-207.9V582.1h77.1v189.7c0 209-.6 199.8 12.6 208 13.4 8 31.4 2.6 37.3-11.2 2.4-5.9 2.9-44.6 2.9-261.7V452.3h21.9c17.2 0 23-.8 28.6-3.7 7.7-4 14.4-14.8 14.4-22.7s-6.7-18.7-14.4-22.7c-6-3.3-12-3.7-44.5-3.7s-38.5.4-44.4 3.7z"/>
</svg>
<h2>789 km²</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum quisquam odio consequuntur aliquam nobis eius voluptatem. Nam eum cumque ullam, quae tenetur sed repellendus non accusamus voluptatum quisquam corporis qui?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum quisquam odio consequuntur aliquam nobis eius voluptatem. Nam eum cumque ullam, quae tenetur sed repellendus non accusamus voluptatum quisquam corporis qui?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum quisquam odio consequuntur aliquam nobis eius voluptatem. Nam eum cumque ullam, quae tenetur sed repellendus non accusamus voluptatum quisquam corporis qui?</p>
</main>
</div>
// ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// Parallax styles
// depends on --pct to be updated by js on scroll
// ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
.parallax {
position: relative;
// aspect ratio sizing
width: 100vw;
height: 50vw;
// transform
transform-origin: bottom center;
will-change: transform;
transform:
translate3d(0, calc(var(--pct) * 35%), 0) // translate down
scale3d(calc(var(--pct)/2 + 1), calc(var(--pct)/2 + 1), 1) // scale to create zoom effect
;
// parallax layers
div {
// stack and make layers fit to wrapper
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
// transform
will-change: transform;
transform-origin: bottom center;
transform: translate3d(0, 0, 0);
// translate up using 2.5% offset on each layer
&.p1 { transform: translate3d(0, calc(var(--pct) * -20.0%), 0); }
&.p2 { transform: translate3d(0, calc(var(--pct) * -17.5%), 0); }
&.p3 { transform: translate3d(0, calc(var(--pct) * -15.0%), 0); }
&.p4 { transform: translate3d(0, calc(var(--pct) * -12.5%), 0); }
&.p5 { transform: translate3d(0, calc(var(--pct) * -10.0%), 0); }
&.p6 { transform: translate3d(0, calc(var(--pct) * -7.5%), 0); }
&.p7 { transform: translate3d(0, calc(var(--pct) * -5.0%), 0); }
&.p8 { transform: translate3d(0, calc(var(--pct) * -2.5%), 0); }
}
}
// a bit of styling
html { box-sizing: border-box; }
*,*:before,*:after { box-sizing: inherit; }
html, body {
margin:0;
background-color: #2b110e;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
header {
overflow: hidden;
box-shadow: inset 0 -4em 4em -4em #2b110e;
}
main {
position: relative; z-index: 1;
min-height: 100vh;
border-top: 1px solid lighten(#2b110e, 5%);
padding: 2em 1em 4em;
max-width: 580px;
margin: 0 auto;
}
@import url('https://fonts.googleapis.com/css?family=Open+Sans|Oswald:200');
.logo {
fill: rgba(#fff, 0.3);
width: .72em;
vertical-align: top;
margin: 0.15em 0.15em 0.15em 0;
}
.separator {
fill: rgba(#fff, 0.1);
height: 2em;
vertical-align: top;
margin: 1em 0 0;
width: 100%;
}
h1 {
margin: 0;
font-family: Oswald;
font-size: 2em;
line-height: 1;
font-weight: 200;
color: rgba(#fff, 0.7);
}
h2 {
margin: 2em 0 0;
font-family: Oswald;
font-size: 1.6em;
line-height: 1;
font-weight: 200;
color: rgba(#fff, 0.7);
}
p,a {
font-family: Open Sans;
color: rgba(#fff, 0.7);
}
.no-iframe {
position: absolute;
top: 2em; right: 1em;
display: none;
transition: 200ms;
z-index:1;
font-size: .7em;
padding: 0.5em;
text-decoration: none;
background-color: #2b110e;
opacity: 0.5;
&:hover { opacity: 0.7; }
}
// passive events
let passiveSupported = false; try { window.addEventListener("test", null, Object.defineProperty({}, "passive", { get: function() { passiveSupported = true; } }));} catch(err) {}
// scroll listener
addEventListener('scroll', e=> {
const height = document.querySelector('.parallax').getBoundingClientRect().height;
const percentage = Math.min(Math.max(pageYOffset/height, 0),1);
document.documentElement.style.setProperty('--pct',percentage);
}, passiveSupported ? { passive: true } : false)
// link to open without iframe
const inIframe = () => { try { return window.self !== window.top;} catch (e) { return true;} }
if(inIframe()) document.querySelector('.no-iframe').style.display = 'block';
Also see: Tab Triggers