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 class="article-container">
<header class="header">
<svg class="example-logo" width="2000px" height="2000px" viewBox="-400 -400 1000 1000" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="icon-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<circle class="rellax" data-rellax-speed="-1" stroke="#000000" stroke-width="3" fill="#333333" style="opacity:.5" cx="100.5" cy="100.5" r="100.5"></circle>
<circle class="rellax" data-rellax-speed="-.5" stroke="#000000" stroke-width="3" fill="#aaa" style="opacity:.5" opacity="0.9" cx="100.5" cy="99.225" r="79.875"></circle>
<g class="rellax" data-rellax-speed="2">
<g class="large-boulder" transform="translate(33.000000, 57.000000)">
<polygon fill="#E6E7E8" points="36 0.15 83.025 0.15 99 12.525 102.6 24.9 134.1 68.775 106.275 78.6 61.275 73.425 8.625 75.45 0.9 61.125 0.9 44.475 12.225 37.8 23.625 16.2"></polygon>
<path d="M8.25,74.325 L31.425,59.7 L47.85,58.5 L64.95,60.6 L83.025,50.325 L108.3,57.15 L134.1,68.775 L106.275,78.6 L61.275,73.425 L37.05,74.1 L8.25,74.325 Z M18.15,27.45 L34.425,28.125 L39.075,33.15 L22.05,39.375 L7.425,51.3 L0.9,45.45 L10.5,38.775 L18.15,27.45 Z M71.175,25.875 L73.875,19.2 L83.85,15.9 L97.5,27.225 L84.375,23.1 L75.825,27.225 L71.175,25.875 Z M37.425,38.85 L58.725,33.15 L70.95,36.375 L79.2,42.525 L74.55,48.225 L59.175,49.275 L45.75,51 L32.85,50.325 L27.225,56.4 L16.35,52.8 L37.425,38.85 Z" fill="#D1D3D4"></path>
<polygon id="body" stroke="#000000" stroke-width="3" points="36 0.15 83.025 0.15 99 12.525 102.6 24.9 134.1 68.775 106.275 78.6 61.275 73.425 8.625 75.45 0.9 61.125 0.9 44.475 12.225 37.8 23.625 16.2"></polygon>
</g>
</g>
<g class="rellax" data-rellax-speed="1.5">
<g class="medium-boulder" transform="translate(108.750000, 125.250000)">
<polygon fill="#F1F2F2" points="0.525 14.025 10.5 3.3 30.675 0.15 38.925 7.05 43.05 20.85 24.45 27.375 4.575 24.75"></polygon>
<polygon fill="#D1D3D4" points="0.525 13.8 18.6 19.35 30.975 18.225 40.275 11.55 43.05 20.625 24.45 27.225 4.575 24.525"></polygon>
<polygon stroke="#000000" stroke-width="3" points="0.525 13.8 10.5 3.075 30.675 0 38.925 6.9 43.05 20.625 24.45 27.225 4.575 24.525"></polygon>
</g>
</g>
<g class="rellax" data-rellax-speed="1.25">
<g class="small-boulder" transform="translate(70.500000, 123.750000)">
<polygon fill="#F1F2F2" points="8.85 2.925 20.025 0 31.125 8.475 33.9 19.425 11.025 26.1 0.225 16.725 5.1 3.825"></polygon>
<polygon fill="#E6E7E8" points="3.9 6.975 14.325 17.625 26.1 12 32.025 12.075 33.9 19.425 11.025 26.1 0.525 15.6"></polygon>
<polygon stroke="#000000" stroke-width="3" points="8.85 2.925 20.025 0 31.125 8.475 33.9 19.425 11.025 26.1 0.225 16.725 5.1 3.825"></polygon>
</g>
</g>
</g>
</svg>
<h1 class="heading rellax" data-rellax-speed="-5">MOON ROCKS</h1>
</header>
<article class="content">
<p>"No nation which expects to be the leader of other nations can expect to stay behind in this race for space. We choose to go to the Moon in this decade and do the other things, not because they are easy, but because they are hard."</p>
<div class="floating-rocks front-one rellax" data-rellax-speed="8">
<img src="https://cssanimation.rocks/levelup/public/03/04-end/images/rock1.svg">
</div>
<p>"10, 9, ignition sequence start, 6, 5, 4, 3, 2, 1, zero. All engines running. Liftoff! We have a liftoff!"</p>
<div class="floating-rocks back-one rellax" data-rellax-speed="-2" data-rellax-percentage="0.5">
<img src="https://cssanimation.rocks/levelup/public/03/04-end/images/rock3.svg">
</div>
<p>"Houston, Tranquility Base here. The Eagle has landed."</p>
<div class="floating-rocks front-two rellax" data-rellax-speed="3" data-rellax-percentage="0.5">
<img src="https://cssanimation.rocks/levelup/public/03/04-end/images/rock2.svg">
</div>
<p>"Here we first set foot upon the Moon. July 1969 AD. We came in peace for all mankind."</p>
<div class="floating-rocks back-two rellax" data-rellax-speed="-3" data-rellax-percentage="0.5">
<img src="https://cssanimation.rocks/levelup/public/03/04-end/images/rock4.svg">
</div>
<p>"This is the LM pilot. I'd like to take this opportunity to ask every person listening in, whoever and wherever they may be, to pause for a moment and contemplate the events of the past few hours and to give thanks in his or her own way."</p>
<div class="floating-rocks planet-earth rellax" data-rellax-speed="-4" data-rellax-percentage="0.5">
<img src="https://cssanimation.rocks/levelup/public/03/04-end/images/earth.png" width="100">
</div>
<p>"That's one small step for man, a giant leap for mankind."</p>
</article>
<footer>
<h1 class="heading rellax" data-rellax-speed="-2" data-rellax-percentage="0.5">MOON ROCKS</h1>
<p class="credit">Images from <a href="https://www.flickr.com/photos/projectapolloarchive/albums">NASA</a> ·
Parallax by <a href="https://github.com/dixonandmoe/rellax">Rellax.js</a> ·
<a href="http://courses.cssanimation.rocks/p/level-up">Learn CSS animation</a></p>
</footer>
</div>
header {
align-items: center;
background: #000 url(https://cssanimation.rocks/levelup/public/03/04-end/images/moon.jpg) center no-repeat;
background-size: 100% auto;
display: flex;
height: 100vh;
position: relative;
overflow: hidden;
justify-content: center;
width: 100vw;
}
header:after {
content: "";
background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,1));
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.example-logo {
z-index: 10;
}
.heading {
color: white;
font-size: 6em;
line-height: 1;
margin: 0;
position: absolute;
right: 0;
left: 0;
bottom: 10vh;
text-align: center;
}
.content {
position: relative;
}
.content p {
transform: translateZ(0);
z-index: 10;
}
.floating-rocks {
position: absolute;
}
.front-one {
right: -10em;
}
.front-two {
left: -12em;
}
.back-one {
left: -4em;
opacity: .2;
z-index: 0;
}
.back-two {
right: -20em;
opacity: .1;
z-index: 0;
}
.planet-earth {
border-radius: 50%;
left: -5em;
opacity: .8;
z-index: 0;
}
footer {
background-size: cover;
background: url(https://cssanimation.rocks/levelup/public/03/04-end/images/moon2.jpg) top center no-repeat;
height: 1014px;
margin-top: 10em;
position: relative;
}
footer .heading {
color: rgba(0,0,0,1);
top: 40%;
bottom: auto;
}
.credit {
font-size: 1.75em;
text-align: center;
margin: 0;
position: absolute;
top: auto;
right: 0;
bottom: .5em;
left: 0;
}
var rellax = new Rellax('.rellax');
Also see: Tab Triggers