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.
<h2>Toilet-roll loader</h2>
<div class="wrapper">
<div class="toiletroll">
<div class="roll"></div>
<div class="papers">
<div class="paper">Loading</div>
<div class="paper">Wait</div>
<div class="paper">Please</div>
</div>
</div>
</div>
$speed: 2s;
@import url(https://fonts.googleapis.com/css?family=Roboto:400);
html {
height: 100%;
}
body {
background: #444;
text-align: center;
}
h2 {
font: bold 35px 'Roboto';
color: #ccc;
text-shadow: 2px 2px 2px black;
}
.wrapper {
display: inline-block;
text-align: left;
position: relative;
width: 120px;
height: 210px;
margin: 15px 0 0 0;
}
.toiletroll {
position: relative;
width: 120px;
height: 210px;
.roll {
position: absolute;
width: 100px;
height: 60px;
background: #eee;
border-radius: 15% 0% 0% 15% / 50% 0% 0% 50%;
box-shadow: inset 0 0 1px rgba(0,0,0,.5),
inset 0 5px 10px rgba(0,0,0,.3);
background-image: linear-gradient(to bottom, #eeeeee 0%,#eeeeee 49%,#bbbbbb 50%,#eeeeee 51%,#eeeeee 100%); /* W3C */
background-size: 100px 60px;
animation: move-roll ($speed / 1.2) linear infinite;
&:before {
position: absolute;
content: "";
z-index: 1;
height: 100%;
width: 20%;
right: -10%;
border-radius: 50%;
background-color: #eee;
animation: anim-rollend ($speed / 10) linear infinite;
background-image: radial-gradient(ellipse at center,
#eeeeee 0%, #eeeeee 4%, #bbbbbb 5%, #eeeeee 6%, #eeeeee 9%,
#bbbbbb 10%, #eeeeee 11%, #eeeeee 14%, #bbbbbb 15%, #eeeeee 16%, #eeeeee 19%,
#bbbbbb 20%, #eeeeee 21%, #eeeeee 24%, #bbbbbb 25%, #eeeeee 26%, #eeeeee 29%,
#bbbbbb 30%, #eeeeee 31%, #eeeeee 34%, #bbbbbb 35%, #eeeeee 36%, #eeeeee 39%,
#bbbbbb 40%, #eeeeee 41%, #eeeeee 44%, #bbbbbb 45%, #eeeeee 46%, #eeeeee 49%,
#bbbbbb 50%, #eeeeee 51%, #eeeeee 54%, #bbbbbb 55%, #eeeeee 56%, #eeeeee 59%,
#bbbbbb 60%, #eeeeee 61%, #eeeeee 64%, #bbbbbb 65%, #eeeeee 66%, #eeeeee 69%,
#bbbbbb 70%, #eeeeee 71%, #eeeeee 74%, #bbbbbb 75%, #eeeeee 76%, #eeeeee 79%,
#bbbbbb 80%, #eeeeee 81%, #eeeeee 84%, #bbbbbb 85%, #eeeeee 86%, #eeeeee 89%,
#bbbbbb 90%, #eeeeee 91%, #eeeeee 94%, #bbbbbb 95%, #eeeeee 96%, #eeeeee 100%);
background-repeat: no-repeat;
box-shadow: inset 0 0 1px rgba(0,0,0,.5);
}
&:after {
position: absolute;
content: "";
z-index: 1;
height: 40%;
width: 8%;
top: 30%;
right: -4%;
border-radius: 50%;
background: black;
box-shadow: inset 0 0 1px rgba(0,0,0,.5);
}
}
.papers {
position: relative;
z-index: -1;
width: 100px;
height: 180px;
top: 30px;
left: 10px;
overflow: hidden;
&:after {
position: absolute;
content: "";
width: 100%;
height: 33%;
box-shadow: inset 0 30px 10px rgba(0,0,0,.2);
}
.paper {
position: absolute;
width: 100px;
height: 60px;
background-color: #eee;
box-shadow: inset 0 0 1px rgba(0,0,0,.5);
text-align: center;
font: bold 15px/60px 'Roboto';
color: #bbb;
text-shadow: -1px -1px 1px rgba(255,255,255,.4),
1px 1px 1px rgba(0,0,0,.4);
animation: move-paper $speed linear infinite;
&:nth-of-type(1) {
}
&:nth-of-type(2) {
animation-delay: (-$speed / 3 ) * 1;
}
&:nth-of-type(3) {
animation-delay: (-$speed / 3 ) * 2;
}
}
}
}
@keyframes move-paper {
0% {
opacity: 1;
transform: translateY(-60px);
}
50% {
transform: translateY(20px);
}
75% {
opacity: 1;
}
100% {
opacity: 0;
transform: translateY(120px);
}
}
@keyframes move-roll {
0% {background-position: 0px 120px;}
100% {background-position: 0px 0px;}
}
@keyframes anim-rollend {
0% {background-size: 100% 100%;background-position: 0 0;}
50% {background-size: 98% 98%;background-position: 1px 1px;}
}
/*
Toilet-roll loader
*/
Also see: Tab Triggers