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.
.container.text-center
.row
.col-sm-2
.sp.sp-circle
h5 Circle
.col-sm-2
.sp.sp-3balls
h5 3 Balls
.col-sm-2
.sp.sp-volume
h5 Volume
.col-sm-2
.sp.sp-vortex
h5 Vortex
.col-sm-2
.sp.sp-slices
h5 Slices
.col-sm-2
.sp.sp-sphere
h5 Sphere
.row
.col-sm-2
.sp.sp-bars
h5 Bars
.col-sm-2
.sp.sp-clock
h5 Clock
.col-sm-2
.sp.sp-wave
h5 Wave
.col-sm-2
.sp.sp-texture
h5 Texture
.col-sm-2
.sp.sp-loadbar
h5 LoadBar
.col-sm-2
.sp.sp-hydrogen
h5 Hydrogen
$spCol: #000;
body {
background-color: #f9f9f9;
margin-top: 25px;
}
.col-sm-2 {
padding: 10px;
border-radius: 4px;
height: 125px;
margin-bottom: 10px;
}
.sp {
width: 32px;
height: 32px;
clear: both;
margin: 20px auto;
}
/* Spinner Circle Rotation */
.sp-circle {
border: 4px rgba($spCol,0.25) solid;
border-top: 4px rgba($spCol,1) solid;
border-radius: 50%;
-webkit-animation: spCircRot .6s infinite linear;
animation: spCircRot .6s infinite linear;
}
@-webkit-keyframes spCircRot {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(359deg); }
}
@keyframes spCircRot {
from { transform: rotate(0deg); }
to { transform: rotate(359deg); }
}
/* Spinner 3Balls Scale */
.sp-3balls, .sp-3balls:before, .sp-3balls:after {
border-radius: 50%;
background-color: $spCol;
width: 18px;
height: 18px;
transform-origin: center center;
display: inline-block;
}
.sp-3balls {
position: relative;
background-color: rgba($spCol,1);
opacity: 1;
-webkit-animation: spScaleAlpha 1s infinite linear;
animation: spScaleAlpha 1s infinite linear;
}
.sp-3balls:before, .sp-3balls:after {
content: '';
position: relative;
opacity: 0.25;
}
.sp-3balls:before {
left: 30px;
top: 0px;
-webkit-animation: spScaleAlphaBefore 1s infinite linear;
animation: spScaleAlphaBefore 1s infinite linear;
}
.sp-3balls:after {
left: -30px;
top: -23px;
-webkit-animation: spScaleAlphaAfter 1s infinite linear;
animation: spScaleAlphaAfter 1s infinite linear;
}
@-webkit-keyframes spScaleAlpha {
0% { opacity: 1; }
33% { opacity: 0.25; }
66% { opacity: 0.25; }
100% { opacity: 1; }
}
@keyframes spScaleAlpha {
0% { opacity: 1; }
33% { opacity: 0.25; }
66% { opacity: 0.25; }
100% { opacity: 1; }
}
@-webkit-keyframes spScaleAlphaBefore {
0% { opacity: 0.25; }
33% { opacity: 1; }
66% { opacity: 0.25; }
}
@keyframes spScaleAlphaBefore {
0% { opacity: 0.25; }
33% { opacity: 1; }
66% { opacity: 0.25; }
}
@-webkit-keyframes spScaleAlphaAfter {
33% { opacity: 0.25; }
66% { opacity: 1; }
100% { opacity: 0.25; }
}
@keyframes spScaleAlphaAfter {
33% { opacity: 0.25; }
66% { opacity: 1; }
100% { opacity: 0.25; }
}
/* Spinner VolumeButton */
.sp-volume {
background-color: $spCol;
border-radius: 50%;
position: relative;
-webkit-animation: spVolRot .6s infinite linear;
animation: spVolRot .6s infinite linear;
}
.sp-volume:after {
content: '';
border-radius: 50%;
position: absolute;
display: block;
width: 10px;
height: 10px;
left: 5px;
top: 5px;
background-color: lighten($spCol,100%);
}
@-webkit-keyframes spVolRot {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(359deg); }
}
@keyframes spVolRot {
from { transform: rotate(0deg); }
to { transform: rotate(359deg); }
}
/* Spinner Vortex */
.sp-vortex {
border: 1px $spCol solid;
border-radius: 4px;
overflow: hidden;
position: relative;
}
.sp-vortex:after, .sp-vortex:before {
content: '';
border-radius: 50%;
position: absolute;
width: inherit;
height: inherit;
-webkit-animation: spVortex 2s infinite linear;
animation: spVortex 2s infinite linear;
}
.sp-vortex:before {
border-top: 6px $spCol solid;
top: -3px;
left: calc( -50% - 3px );
transform-origin: right center;
}
.sp-vortex:after {
border-bottom: 6px $spCol solid;
top: 3px;
right: calc( -50% - 3px );
transform-origin: left center;
}
@-webkit-keyframes spVortex {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(359deg); }
}
@keyframes spVortex {
from { transform: rotate(0deg); }
to { transform: rotate(359deg); }
}
/* Spinner Slices */
.sp.sp-slices {
border-radius: 50%;
border-top: 16px rgba($spCol,0.75) solid;
border-left: 16px rgba($spCol,0.25) solid;
border-bottom: 16px rgba($spCol,0.25) solid;
border-right: 16px rgba($spCol,0.25) solid;
-webkit-animation: spSlices 1s infinite linear;
animation: spSlices 1s infinite linear;
}
@-webkit-keyframes spSlices {
0% {
border-top: 16px rgba($spCol,0.75) solid;
border-right: 16px rgba($spCol,0.25) solid;
border-bottom: 16px rgba($spCol,0.25) solid;
border-left: 16px rgba($spCol,0.25) solid;
}
25% {
border-top: 16px rgba($spCol,0.25) solid;
border-right: 16px rgba($spCol,0.75) solid;
border-bottom: 16px rgba($spCol,0.25) solid;
border-left: 16px rgba($spCol,0.25) solid;
}
50% {
border-top: 16px rgba($spCol,0.25) solid;
border-right: 16px rgba($spCol,0.25) solid;
border-bottom: 16px rgba($spCol,0.75) solid;
border-left: 16px rgba($spCol,0.25) solid;
}
75% {
border-top: 16px rgba($spCol,0.25) solid;
border-right: 16px rgba($spCol,0.25) solid;
border-bottom: 16px rgba($spCol,0.25) solid;
border-left: 16px rgba($spCol,0.75) solid;
}
100% {
border-top: 16px rgba($spCol,0.75) solid;
border-right: 16px rgba($spCol,0.25) solid;
border-bottom: 16px rgba($spCol,0.25) solid;
border-left: 16px rgba($spCol,0.25) solid;
}
}
@keyframes spSlices {
0% {
border-top: 16px rgba($spCol,0.75) solid;
border-right: 16px rgba($spCol,0.25) solid;
border-bottom: 16px rgba($spCol,0.25) solid;
border-left: 16px rgba($spCol,0.25) solid;
}
25% {
border-top: 16px rgba($spCol,0.25) solid;
border-right: 16px rgba($spCol,0.75) solid;
border-bottom: 16px rgba($spCol,0.25) solid;
border-left: 16px rgba($spCol,0.25) solid;
}
50% {
border-top: 16px rgba($spCol,0.25) solid;
border-right: 16px rgba($spCol,0.25) solid;
border-bottom: 16px rgba($spCol,0.75) solid;
border-left: 16px rgba($spCol,0.25) solid;
}
75% {
border-top: 16px rgba($spCol,0.25) solid;
border-right: 16px rgba($spCol,0.25) solid;
border-bottom: 16px rgba($spCol,0.25) solid;
border-left: 16px rgba($spCol,0.75) solid;
}
100% {
border-top: 16px rgba($spCol,0.75) solid;
border-right: 16px rgba($spCol,0.25) solid;
border-bottom: 16px rgba($spCol,0.25) solid;
border-left: 16px rgba($spCol,0.25) solid;
}
}
/* Spinner Sphere */
.sp-sphere {
border-radius: 50%;
border-left: 0px $spCol solid;
border-right: 0px $spCol solid;
-webkit-animation: spSphere 1s infinite linear;
animation: spSphere 1s infinite linear;
}
@-webkit-keyframes spSphere {
0% {
border-left: 0px $spCol solid;
border-right: 0px $spCol solid;
}
33% {
border-left: 32px $spCol solid;
border-right: 0px $spCol solid;
}
34% {
border-left: 0px $spCol solid;
border-right: 32px $spCol solid;
}
66% {
border-left: 0px $spCol solid;
border-right: 0px $spCol solid;
}
}
@keyframes spSphere {
0% {
border-left: 0px $spCol solid;
border-right: 0px $spCol solid;
}
33% {
border-left: 32px $spCol solid;
border-right: 0px $spCol solid;
}
34% {
border-left: 0px $spCol solid;
border-right: 32px $spCol solid;
}
66% {
border-left: 0px $spCol solid;
border-right: 0px $spCol solid;
}
}
/* Spinner Bars */
.sp-bars {
position: relative;
width: 10px;
border: 1px $spCol solid;
background-color: rgba($spCol,0.25);
-webkit-animation: spBars 1s infinite linear;
animation: spBars 1s infinite linear;
}
.sp-bars:after, .sp-bars:before {
content:'';
position: absolute;
width: inherit;
height: inherit;
border: inherit;
background-color: inherit;
top: -1px;
}
.sp-bars:before {
left: -20px;
-webkit-animation: spBarsBefore 1s infinite linear;
animation: spBarsBefore 1s infinite linear;
}
.sp-bars:after {
right: -20px;
-webkit-animation: spBarsAfter 1s infinite linear;
animation: spBarsAfter 1s infinite linear;
}
@keyframes spBarsBefore {
0% {
transform: scale(1,1);
}
25% {
transform: scale(1,1.25);
}
50% {
transform: scale(1,0.75);
}
75% {
transform: scale(1,1);
}
100% {
transform: scale(1,1);
}
}
@keyframes spBars {
0% {
transform: scale(1,1);
}
25% {
transform: scale(1,1);
}
50% {
transform: scale(1,1.25);
}
75% {
transform: scale(1,1);
}
100% {
transform: scale(1,1);
}
}
@keyframes spBarsAfter {
0% {
transform: scale(1,1);
}
25% {
transform: scale(1,1);
}
50% {
transform: scale(1,0.75);
}
75% {
transform: scale(1,1.25);
}
100% {
transform: scale(1,1);
}
}
/* Spinner Clock */
.sp-clock {
border: 1px $spCol solid;
border-radius: 50%;
position: relative;
}
.sp-clock:before {
content:'';
border-left: 1px $spCol solid;
position: absolute;
top: 2px;
width: 1px;
height: calc( 50% - 2px );
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
-ms-transform-origin: 0% 100%;
-webkit-transform-origin: 0% 100%;
transform-origin: 0% 100%;
-webkit-animation: spClock 1s infinite linear;
animation: spClock 1s infinite linear;
}
@-webkit-keyframes spClock {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(359deg); }
}
@keyframes spClock {
from { transform: rotate(0deg); }
to { transform: rotate(359deg); }
}
/* Spinner Wave */
.sp-wave {
border-radius: 50%;
position: relative;
opacity: 1;
}
.sp-wave:before, .sp-wave:after {
content:'';
border: 1px $spCol solid;
border-radius: 50%;
width: 100%;
height: 100%;
position: absolute;
left:0px;
}
.sp-wave:before {
transform: scale(1,1);
opacity: 1;
-webkit-animation: spWaveBe 0.6s infinite linear;
animation: spWaveBe 0.6s infinite linear;
}
.sp-wave:after {
transform: scale(0,0);
opacity: 0;
-webkit-animation: spWaveAf 0.6s infinite linear;
animation: spWaveAf 0.6s infinite linear;
}
@-webkit-keyframes spWaveAf {
from { -webkit-transform: scale(0.5,0.5); opacity: 0; }
to { -webkit-transform: scale(1,1); opacity: 1; }
}
@keyframes spWaveAf {
from { transform: scale(0.5,0.5); opacity: 0; }
to { transform: scale(1,1); opacity: 1; }
}
@-webkit-keyframes spWaveBe {
from { -webkit-transform: scale(1,1); opacity: 1; }
to { -webkit-transform: scale(1.5,1.5); opacity: 0; }
}
@keyframes spWaveBe {
from { -webkit-transform: scale(1,1); opacity: 1; }
to { -webkit-transform: scale(1.5,1.5); opacity: 0; }
}
/* Spinner Texture */
.sp-texture {
border: 1px $spCol solid;
border-radius: 4px;
position: relative;
background: linear-gradient(45deg, transparent 49%, $spCol 50%, $spCol 50%, transparent 51%, transparent),
linear-gradient(-45deg, transparent 49%, $spCol 50%, $spCol 50%, transparent 51%, transparent);
background-size: 16px 16px;
background-position: 0% 0%;
-webkit-animation: spTexture 1s infinite linear;
animation: spTexture 1s infinite linear;
}
@-webkit-keyframes spTexture {
from { background-position: 0px 0px; }
to { background-position: -16px 0px; }
}
@keyframes spTexture {
from { background-position: 0px 0px; }
to { background-position: -16px 0px; }
}
/* Spinner LoadBar */
.sp-loadbar {
width: 50px;
height: 18px;
border: 1px $spCol solid;
border-radius: 4px;
background: linear-gradient(-60deg, transparent 0%, transparent 50%, $spCol 50%, $spCol 75%, transparent 75%, transparent);
background-size: 20px 30px;
background-position: 0px 0px;
-webkit-animation: spLoadBar 0.8s infinite linear;
animation: spLoadBar 0.8s infinite linear;
}
@-webkit-keyframes spLoadBar {
from { background-position: 0px 0px; }
to { background-position: -20px 0px; }
}
@keyframes spLoadBar {
from { background-position: 0px 0px; }
to { background-position: -20px 0px; }
}
/* Spinner Hydrogen */
.sp-hydrogen {
position: relative;
border: 1px $spCol solid;
border-radius: 50%;
-webkit-animation: spHydro 0.6s infinite linear;
animation: spHydro 0.6s infinite linear;
}
.sp-hydrogen:before, .sp-hydrogen:after {
content: '';
position: absolute;
width: 10px;
height: 10px;
background-color: $spCol;
border-radius: 50%;
}
.sp-hydrogen:before {
top: calc( 50% - 5px );
left: calc( 50% - 5px );
}
.sp-hydrogen:after {
top: -1px;
left: -1px;
}
@-webkit-keyframes spHydro {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(359deg); }
}
@keyframes spHydro {
from { transform: rotate(0deg); }
to { transform: rotate(359deg); }
}
Also see: Tab Triggers