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.
<header class="hero">
<div class="container">
<a class="logo" href="#">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/513927/logo.png" alt="Logo">
</a>
<div class="hands"></div>
<div class="book"></div>
<div class="skull"></div>
<div class="flowers"></div>
</div>
</header>
<main class="content">
<div class="container">
<p>Lorem ipsum dolor amet cardigan tumeric flannel ethical fixie, poutine church-key cliche taxidermy mustache slow-carb schlitz hashtag. Truffaut poutine you probably haven't heard of them pork belly listicle vinyl jianbing kombucha. Slow-carb disrupt chartreuse, truffaut williamsburg ramps DIY cronut distillery. Meh pork belly letterpress, fingerstache VHS ethical vape you probably haven't heard of them. Stumptown pitchfork etsy kinfolk pabst. Heirloom copper mug sartorial cornhole. PBR&B raw denim chicharrones chia pabst helvetica wayfarers waistcoat viral bespoke.</p>
<p>Shabby chic synth biodiesel squid tattooed forage meditation yuccie, 3 wolf moon banh mi tumblr master cleanse. Marfa chicharrones brunch kitsch trust fund bushwick schlitz pitchfork post-ironic gochujang unicorn. Kombucha godard migas pinterest narwhal, air plant banjo wayfarers try-hard activated charcoal glossier normcore. Stumptown chillwave cardigan etsy actually banjo. Stumptown fashion axe meggings keytar blue bottle. Semiotics cray tumeric migas fanny pack lyft beard hot chicken seitan. Echo park put a bird on it kickstarter, tattooed deep v selvage narwhal banh mi poutine scenester photo booth truffaut DIY.</p>
<p>Irony pok pok intelligentsia meh photo booth. Wayfarers ethical viral, adaptogen neutra chartreuse shoreditch pitchfork semiotics tousled irony. Taxidermy fam food truck ugh tofu freegan. Tbh lo-fi biodiesel poutine activated charcoal godard vinyl truffaut austin. Street art four dollar toast hashtag hammock, actually authentic next level deep v quinoa chia.</p>
<p>Meh food truck pok pok, hexagon shabby chic authentic neutra woke mixtape pinterest trust fund umami blue bottle. 90's jean shorts chicharrones sustainable, brunch banh mi skateboard la croix narwhal DIY offal microdosing put a bird on it readymade small batch. Man braid VHS chillwave helvetica PBR&B retro shabby chic iPhone kogi iceland echo park dreamcatcher actually. DIY keytar hoodie street art intelligentsia. Raclette paleo echo park truffaut, vegan meggings shoreditch neutra vexillologist chia kickstarter. Thundercats next level readymade bitters ethical butcher chillwave stumptown fixie keytar trust fund selvage cold-pressed adaptogen vice. Etsy lo-fi poke beard bushwick, asymmetrical authentic you probably haven't heard of them pok pok.</p>
<p>Meditation raclette church-key craft beer umami fanny pack activated charcoal listicle meh chicharrones 8-bit poutine. Normcore DIY tote bag taiyaki organic. Sartorial poke pabst pour-over dreamcatcher palo santo ethical williamsburg polaroid. Kitsch meh photo booth health goth kogi blog pug tilde synth narwhal skateboard ugh woke. Vaporware enamel pin salvia health goth flexitarian glossier truffaut. Prism VHS godard, fanny pack affogato craft beer actually chambray woke chicharrones truffaut succulents brooklyn. Marfa banh mi vegan master cleanse.</p>
</div>
</main>
html body {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
line-height: 40px;
}
.hero {
display: flex;
justify-content: center;
height: 600px;
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/513927/table-bg.jpg');
background-repeat: no-repeat;
background-position: center;
background-size: cover;
background-attachment: fixed;
overflow: hidden;
}
.hero .container {
position: relative;
height: 100%;
}
.container {
width: 100%;
max-width: 1200px;
}
.content {
margin: 80px 0;
display: flex;
justify-content: center;
}
/* Parallax Elements */
.logo {
position: absolute;
width: 130px;
top: 20px;
left: 0;
right: 0;
margin: auto;
display: block;
z-index: 1;
}
.logo img {
display: block;
width: 130px;
}
.hands {
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 525px;
height: 347px;
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/513927/hands.png');
background-size: contain;
background-repeat: no-repeat;
z-index: 2;
}
.book {
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 480px;
height: 361px;
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/513927/book.png');
background-size: contain;
background-repeat: no-repeat;
bottom: -240px;
}
.skull {
position: absolute;
align-self: center;
top: 200px;
left: 8%;
width: 180px;
height: 161px;
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/513927/skull.png');
background-size: contain;
background-repeat: no-repeat;
}
.flowers {
position: absolute;
right: 0;
top: 10%;
width: 320px;
height: 280px;
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/513927/flowers.png');
background-size: contain;
background-repeat: no-repeat;
}
const hands = document.querySelector('.hands'),
book = document.querySelector('.book'),
skull = document.querySelector('.skull'),
flowers = document.querySelector('.flowers'),
logo = document.querySelector('.logo');
window.addEventListener('scroll', e => {
const heroHeight = document.querySelector('.hero').clientHeight;
let scroll = window.scrollY;
if(scroll <= heroHeight) {
hands.style.transform = `translate(0px, -${scroll / 13}%)`;
skull.style.transform = `translate(0px, ${scroll / 3}%)`;
book.style.transform = `translate(0px, -${scroll / 5}%)`;
flowers.style.transform = `translate(0px, ${scroll / 4}%)`;
logo.style.transform = `translate(0px, ${scroll / 1.2}%)`;
}
});
Also see: Tab Triggers