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 URL's 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 it's URL and the proper URL extention.
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.
<section class="blackie">
<div class="stars">
<div class="pos1 st1"></div>
<div class="pos2 st1"></div>
<div class="pos3 st1"></div>
<div class="pos4 st1"></div>
<div class="pos5 st1"></div>
<div class="pos6 st1"></div>
<div class="pos7 st1"></div>
</div>
<div class="moon"></div>
<div class="cloud blackie">
<div class="cloud1"><div></div></div>
<div class="cloud2"><div></div></div>
<div class="cloud3"><div></div></div>
</div>
<div class="mountain">
<div class="mount1"></div>
</div>
<div class="river">
</div>
<div class="plants">
</div>
</section>
@import "compass/css3";
@import "compass";
$cloud:#3af;
$cloud:rgba(51, 170, 255, 1);
@mixin keyframes($animationName) {
@-webkit-keyframes #{$animationName} {
@content;
}
@-moz-keyframes #{$animationName} {
@content;
}
@-o-keyframes #{$animationName} {
@content;
}
@keyframes #{$animationName} {
@content;
}
}
@mixin transition($transition-property, $transition-time, $method) {
-webkit-transition: $transition-property $transition-time $method;
-moz-transition: $transition-property $transition-time $method;
-ms-transition: $transition-property $transition-time $method;
-o-transition: $transition-property $transition-time $method;
transition: $transition-property $transition-time $method;
}
html, body{
overflow-x:hidden;
margin:0;padding:0;
}
.blackie{
background: #555;
}
section{
display:block;
overflow:hidden;
height:600px;
width:100%;
}
.cloud{
width:100%;
overflow:hidden;
& > div{
position: absolute;
width: 100%;
height: 300px;
}
.cloud1{
border-radius: 50%;
margin-top: 120px;
@include experimental('animation', move-clouds, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', 25s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', ease-out, $animation-support...);
& div{
border-radius: 50%;
width: 150px;
height: 120px;
background-color: $cloud;
@include background-image(radial-gradient(45px 45px, #3af 10px, dodgerblue 30px));
position: absolute;
}
& div:after{
content: " ";
border-radius: 70%;
width: 180px;
height: 110px;
background-color: $cloud;
@include background-image(radial-gradient(45px 45px, #39f 10px, dodgerblue 30px));
position: absolute;
margin-left: 50px;
}
& div:before{
content: " ";
border-radius: 50%;
width: 120px;
height: 70px;
background-color: $cloud;
@include background-image(radial-gradient(45px 45px, #2ea0ff 10px, #1e90ff 30px));
position: absolute;
margin-left: 90px;
margin-top: 80px;
}
}.cloud3{
border-radius: 50%;
margin-top: 50px;
@include experimental('animation', move-clouds3, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', 20s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', linear, $animation-support...);
& div{
border-radius: 60%;
width: 140px;
height: 110px;
background-color: $cloud;
@include background-image(radial-gradient(45px 45px, #3af 10px, dodgerblue 30px));
position: absolute;
}
& div:after{
content: " ";
border-radius: 78%;
width: 180px;
height: 110px;
background-color: $cloud;
position: absolute;
@include background-image(radial-gradient(45px 45px, #39f 10px, dodgerblue 30px));
margin-left: 40px;
}
& div:before{
content: " ";
border-radius: 50%;
width: 150px;
height: 70px;
background-color: $cloud;
position: absolute;
margin-left: 50px;
margin-top: 70px;
}
}
.cloud2{
margin-top: 100px;
@include experimental('animation', move-clouds-2, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', 30s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', linear, $animation-support...);
& div{
border-radius: 50%;
width: 190px;
height: 120px;
background-color: $cloud;
@include background-image(radial-gradient(45px 45px, hsl(210,100%,55%) 15px, #1e90ff 30px));
position: absolute;
}
& div:after{
content: " ";
border-radius: 50%;
width: 180px;
height: 90px;
background-color: hsl(210,100%,45%);
@include background-image(radial-gradient(45px 45px, #39f 10px, dodgerblue 30px));
position: absolute;
margin-left: 60px;
margin-top: -20px;
}
& div:before{
content: " ";
border-radius: 50%;
width: 180px;
height: 80px;
background-color: $cloud;
position: absolute;
margin-left: 40px;
margin-top: 50px;
}
}
}
@include keyframes(move-clouds) {
0% {
@include transform( translateX(100%) );
}
100% {
@include transform( translateX(-25%) );
}
}
@include keyframes(move-clouds3) {
0% {
@include transform( translateX(30%) );
opacity:1;
}
60% {
@include transform( translateX(-25%) );
opacity:1;
}
61% {
@include transform( translateX(-25%) );
opacity:0;
display:none;
}
62% {
@include transform( translateX(100%) );
opacity:0;
display:none;
}
63% {
@include transform( translateX(100%) );
opacity:1;
display:block;
}
100% {
@include transform( translateX(30%) );
opacity:1;
}
}
@include keyframes(move-clouds-2) {
0% {
@include transform( translateX(10%) );
opacity:1;
}
10% {
@include transform( translateX(-25%) );
opacity:1;
}
11% {
@include transform( translateX(-25%) );
opacity:0;
display:none;
}
12% {
@include transform( translateX(100%) );
opacity:0;
display:none;
}
13% {
@include transform( translateX(100%) );
opacity:1;
display:block;
}
100% {
@include transform( translateX(10%) );
opacity:1;
}
}
.mountain{
height:400px;
width:100%;
overflow:hidden;
& div.mount1{
background-color:#989;
height:400px;
margin-top:200px;
width:400px;
@include transform( rotate(40deg) );
&:before{
background-color:#989;
content:" ";
margin-top:-200px;
height:400px;
margin-left:400px;
width:400px;
position:absolute;
}
}
}
.river{
border-top:1px solid #999;
width:100%;
height:200px;
background-color:#78f;
}
.moon{
position:absolute;
top:30px;
right:40px;
height:120px;
width:120px;
border-radius:100%;
border:40px solid #fffff1;
box-shadow:0 0 100px 20px #ffffc0;
background-color:#fffff1;
}
.padding-0{
padding:0px;
}
.stars{
.pos1{
@include transform( scale(.3) );
margin:50px;
@include experimental('animation', star-blinking1, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', .8s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', linear, $animation-support...);
}
.pos2{
@include transform( scale(.6) );
margin:30px 60%;
@include experimental('animation', star-blinking2, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', 1s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', linear, $animation-support...);
}
.pos3{
margin:60px 15%;
@include transform( scale(.8) );
@include experimental('animation', star-blinking3, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', .9s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', linear, $animation-support...);
}
.pos4{
margin:50px 30%;
@include transform( scale(.7) );
@include experimental('animation', star-blinking4, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', 1.1s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', linear, $animation-support...);
}
.pos5{
margin:120px 10%;
@include transform( scale(1) );
@include experimental('animation', star-blinking5, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', 1s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', linear, $animation-support...);
}
.pos6{
margin:140px 35%;
@include transform( scale(.9) );
@include experimental('animation', star-blinking6, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', .7s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', linear, $animation-support...);
}
.pos7{
margin:100px 50%;
@include transform( scale(.5) );
@include experimental('animation', star-blinking7, webkit, moz, o, ms, not khtml);
@include experimental('animation-duration', 1.2s, webkit, moz, o, ms, not khtml);
$animation-support: webkit, moz, o, ms, not khtml;
@include experimental('animation-iteration-count', infinite, $animation-support...);
@include experimental('animation-timing-function', linear, $animation-support...);
}
.st1{
position:absolute;
&:after{
content:" ";
position:absolute;
width:0;
height:0;
border:0;
border-left:10px solid transparent;
border-right:10px solid transparent;
border-top:20px solid #ff8;
@include transform-origin( 50%, 50%);
@include transform( rotate(60deg) );
}
&:before{
content:" ";
position:absolute;
width:0;
height:0;
margin-top:-4px;
border:0;
border-left:10px solid transparent;
border-right:10px solid transparent;
border-top:20px solid #ff8;
@include transform-origin( 50%, 50%);
@include transform( rotate(120deg) );
}
}
}
@include keyframes(star-blinking1) {
0% {
@include transform( scale(.3) );
opacity:.8;
@include transform-origin( 50%, 50%);
}
50% {
@include transform-origin( 50%, 50%);
@include transform( scale(.4) );
opacity:.9;
}
100% {
@include transform( scale(.3) );
@include transform-origin( 50%, 50%);
opacity:.8;
}
}
@include keyframes(star-blinking2) {
0% {
@include transform( scale(.6) );
opacity:.8;
@include transform-origin( 50%, 50%);
}
50% {
@include transform-origin( 50%, 50%);
@include transform( scale(.7) );
opacity:.9;
}
100% {
@include transform( scale(.6) );
@include transform-origin( 50%, 50%);
opacity:.8;
}
}
@include keyframes(star-blinking3) {
0% {
@include transform( scale(.8) );
opacity:.8;
@include transform-origin( 50%, 50%);
}
50% {
@include transform-origin( 50%, 50%);
@include transform( scale(.7) );
opacity:.9;
}
100% {
@include transform( scale(.8) );
@include transform-origin( 50%, 50%);
opacity:.8;
}
}
@include keyframes(star-blinking4) {
0% {
@include transform( scale(.7) );
opacity:.8;
@include transform-origin( 50%, 50%);
}
50% {
@include transform-origin( 50%, 50%);
@include transform( scale(.6) );
opacity:.9;
}
100% {
@include transform( scale(.7) );
@include transform-origin( 50%, 50%);
opacity:.8;
}
}
@include keyframes(star-blinking5) {
0% {
@include transform( scale(1) );
opacity:.8;
@include transform-origin( 50%, 50%);
}
50% {
@include transform-origin( 50%, 50%);
@include transform( scale(.9) );
opacity:.9;
}
100% {
@include transform( scale(1) );
@include transform-origin( 50%, 50%);
opacity:.8;
}
}
@include keyframes(star-blinking6) {
0% {
@include transform( scale(.9) );
opacity:.8;
@include transform-origin( 50%, 50%);
}
50% {
@include transform-origin( 50%, 50%);
@include transform( scale(.8) );
opacity:.9;
}
100% {
@include transform( scale(.9) );
@include transform-origin( 50%, 50%);
opacity:.8;
}
}
@include keyframes(star-blinking7) {
0% {
@include transform( scale(.5) );
opacity:.8;
@include transform-origin( 50%, 50%);
}
50% {
@include transform-origin( 50%, 50%);
@include transform( scale(.6) );
opacity:.9;
}
100% {
@include transform( scale(.5) );
@include transform-origin( 50%, 50%);
opacity:.8;
}
}
.plants{
clear:both;
height:100px;
border:5px dashed #9fa;
width:100%;
background-color:#9fa;
}
Also see: Tab Triggers