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="title paralax" style="background-image: url(https://ik.imagekit.io/fliptopbox/ariel-airport.jpg?tr=tr:n-landscape)">
<h1>Parallax Page</h1>
<em>A simple demo of parallax page elements using CSS & HTML only</em>
</div>
<div class="container">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed suscipit quam non orci aliquam imperdiet. Sed vel ipsum ac massa hendrerit bibendum. In commodo sit amet mi a dapibus. Nullam vestibulum congue eros, posuere fringilla felis condimentum semper. Maecenas porttitor dignissim scelerisque. Curabitur ac viverra quam, ut auctor metus. Suspendisse varius, sapien eu cursus vulputate, ante lacus lacinia arcu, ut convallis est erat ut nulla. Cras tempus vel dolor a auctor. Vestibulum aliquet purus felis, et ullamcorper risus placerat et.</p>
<p>Donec non pharetra leo. Integer nec tortor nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin vitae massa iaculis, cursus lorem accumsan, iaculis libero. Phasellus consequat id lectus sit amet auctor. Maecenas tristique arcu sem, sed pretium nulla gravida ut. Nulla a dictum libero. Integer sodales fermentum enim, eu aliquet risus mollis imperdiet. Donec sit amet augue eu erat placerat auctor eget vitae purus.</p>
</div>
</div>
<div>
<div class="title paralax letterbox" style="background-image:url(https://ik.imagekit.io/fliptopbox/window-shopper.jpg?tr=tr:n-landscape)">
<h1>Postbox Reveal</h1>
</div>
<div class="container">
<p>Nulla vitae scelerisque risus, finibus tincidunt ipsum. Sed ipsum orci, bibendum a ante a, blandit feugiat ligula. Integer eget turpis vehicula, vehicula lacus et, sollicitudin nibh. Integer vulputate sem velit, id sollicitudin lacus porttitor eget. Donec fringilla dictum aliquam. Ut dignissim lacus tellus, quis sodales nisi elementum non. Mauris faucibus bibendum risus vitae varius. Nulla egestas accumsan dictum. Etiam vel ex ut ante finibus sodales eu et sapien. Fusce euismod leo sit amet posuere posuere. Fusce dictum mi id gravida maximus. Integer blandit urna est, ac euismod justo lobortis sed. Nulla ultricies nisl eros. Nunc imperdiet sed lectus ac feugiat. Fusce tincidunt tempor sapien.</p>
</div>
</div>
<div>
<div class="title paralax letterbox" style="background-image:url(https://ik.imagekit.io/fliptopbox/turbine-engine.jpg?tr=tr:n-landscape)">
</div>
<div class="title paralax letterbox" style="background-image:url(https://ik.imagekit.io/fliptopbox/turbine-engine.jpg?tr=w-2160,h-1080);background-size:unset;">
</div>
<div class="title paralax letterbox" style="background-image:url(https://ik.imagekit.io/fliptopbox/turbine-engine.jpg?tr=tr:n-landscape);background-size: 60%;background-repeat: repeat;">
</div>
<div class="title paralax letterbox" style="background-image:url(https://ik.imagekit.io/fliptopbox/turbine-engine.jpg?tr=tr:n-landscape)">
</div>
<div class="container">
<h1>Irregular Venetian Blinds</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed suscipit quam non orci aliquam imperdiet. Sed vel ipsum ac massa hendrerit bibendum. In commodo sit amet mi a dapibus. Nullam vestibulum congue eros, posuere fringilla felis condimentum semper. Maecenas porttitor dignissim scelerisque. Curabitur ac viverra quam, ut auctor metus. Suspendisse varius, sapien eu cursus vulputate, ante lacus lacinia arcu, ut convallis est erat ut nulla. Cras tempus vel dolor a auctor. Vestibulum aliquet purus felis, et ullamcorper risus placerat et.</p>
</div>
</div>
<div class="gallery">
<div class="title paralax square" style="background-image:url(https://ik.imagekit.io/fliptopbox/underground-tunnel.jpg?tr=w-500,h-500,fo-auto)">
</div>
<div class="title paralax square" style="background-image:url(https://ik.imagekit.io/fliptopbox/untitled-test-pattern.jpg?tr=w-500,h-500,fo-auto)">
</div>
<div class="title paralax square" style="background-image:url(https://ik.imagekit.io/fliptopbox/lamb-of-god-zurbaran-agnus.jpg?tr=w-500,h-500,fo-auto)">
</div>
<div class="title paralax square" style="background-image:url(https://ik.imagekit.io/fliptopbox/inferno.jpg?tr=w-500,h-500,fo-auto)">
</div>
<div class="title paralax square" style="background-image:url(https://ik.imagekit.io/fliptopbox/gargoyles.jpg?tr=w-500,h-500,fo-auto)">
</div>
<div class="title paralax square" style="background-image:url(https://ik.imagekit.io/fliptopbox/ancient-egypt.jpg?tr=w-500,h-500,fo-auto)">
</div>
</div>
<div class="container">
<h1>Paralax Preview Gallery</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed suscipit quam non orci aliquam imperdiet. Sed vel ipsum ac massa hendrerit bibendum. In commodo sit amet mi a dapibus. Nullam vestibulum congue eros, posuere fringilla felis condimentum semper. Maecenas porttitor dignissim scelerisque. Curabitur ac viverra quam, ut auctor metus. Suspendisse varius, sapien eu cursus vulputate, ante lacus lacinia arcu, ut convallis est erat ut nulla. Cras tempus vel dolor a auctor. Vestibulum aliquet purus felis, et ullamcorper risus placerat et.</p>
</div>
<div>
<div class="title paralax" style="background-image:url(https://ik.imagekit.io/fliptopbox/origami-crane.jpg?tr=tr:n-landscape)">
<h1>Origami Crane</h1>
</div>
<div class="container">
<p>Curabitur commodo in eros a varius. Morbi mi eros, mollis eget neque vitae, mattis cursus dui. Vestibulum eget ex eget ex efficitur tempor. Duis non ante interdum, volutpat justo pellentesque, finibus odio. Duis vestibulum rutrum accumsan. Nullam in semper tellus. Curabitur elementum elit nibh.</p>
<p>Nulla vitae scelerisque risus, finibus tincidunt ipsum. Sed ipsum orci, bibendum a ante a, blandit feugiat ligula. Integer eget turpis vehicula, vehicula lacus et, sollicitudin nibh. Integer vulputate sem velit, id sollicitudin lacus porttitor eget. Donec fringilla dictum aliquam. Ut dignissim lacus tellus, quis sodales nisi elementum non. Mauris faucibus bibendum risus vitae varius. Nulla egestas accumsan dictum. Etiam vel ex ut ante finibus sodales eu et sapien. Fusce euismod leo sit amet posuere posuere. Fusce dictum mi id gravida maximus. Integer blandit urna est, ac euismod justo lobortis sed. Nulla ultricies nisl eros. Nunc imperdiet sed lectus ac feugiat. Fusce tincidunt tempor sapien.</p>
<p>
</p>
</div>
</div>
html,
body {
height: 100%;
margin: 0;
font-size: 24px;
}
.paralax {
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.title {
/* BG image set on div */
background-color: #112233;
color: white;
height: 100vh;
position: relative;
padding: 0;
}
.title.letterbox {
height: 33vh;
display: flex;
align-items: center;
}
.title.letterbox h1 {
padding: 0;
bottom: unset;
margin: auto auto;
}
.title.square {
width: 300px;
height: 300px;
flex: auto;
margin: 1vh;
}
.gallery {
display: flex;
width: 100%;
margin: auto;
max-width: 1110px;
flex-direction: row;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
.title h1 {
margin: auto 0;
position: absolute;
bottom: 0;
font-weight: bold;
font-size: 4em;
width: 100%;
text-align: center;
padding-bottom: 10vh;
z-index: 1;
}
.title em {
margin: auto 0;
position: absolute;
top: 0;
font-size: 1em;
width: 100%;
text-align: center;
padding-top: 5vh;
z-index: 1;
}
.title:after {
position: absolute;
content: "";
background: #00000022;
width: 100%;
height: 100%;
}
.container {
max-width: 900px;
margin: auto;
padding: 5% 15%;
}
Also see: Tab Triggers