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.
<article>
<p>This is how much Jeff Bezos made...</p>
<output>
<span class="symbol">$</span>
<span class="number u8"></span>
<span class="number u7"></span>
<span class="number u6"></span>
<span class="symbol u6">,</span>
<span class="number u5"></span>
<span class="number u4"></span>
<span class="number u3"></span>
<span class="symbol">,</span>
<span class="number u2"></span>
<span class="number u1"></span>
<span class="number u0"></span>
</output>
<p>...since you started reading this page.</p>
</article>
<footer>
<a href="https://github.com/alvaromontoro/bezos-calculator" target="_blank">See how this number was calculated</a>
</footer>
html, body {
--size: 1.5rem;
margin: 0;
padding: 0;
width: 100%;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-family: Palatino, Helvetica, arial, sans-serif;
overflow: hidden;
}
article {
font-size: 5vmin;
}
article p {
text-shadow:
0 -1px 1px #fff, 1px -1px 1px #fff, 1px 0 1px #fff,
1px 1px 1px #fff, 0 1px 1px #fff, -1px 1px 1px #fff,
-1px 0 1px #fff, -1px -1px 1px #fff;
}
output {
display: flex;
justify-content: center;
}
output span {
font-family: monospace, monospace;
color: white;
background: black;
position: relative;
z-index: 2;
padding: 0;
box-sizing: border-box;
overflow: hidden;
animation: show 0.125s linear 1;
animation-fill-mode: forwards;
font-size: var(--size);
height: calc(var(--size) * 1.5);
line-height: calc(var(--size) * 1.5);
border-radius: 0.25rem;
width: 0;
margin: 0;
}
@keyframes show {
100% {
width: var(--size);
margin: calc(var(--size) * 0.0625);
}
}
span.u0 { animation-delay: 0.0000000000s; }
span.u1 { animation-delay: 0.0022739251s; }
span.u2 { animation-delay: 0.0277392510s; }
span.u3 { animation-delay: 0.2773925104s; }
span.u4 { animation-delay: 2.7739251040s; }
span.u5 { animation-delay: 27.739251040s; }
span.u6 { animation-delay: 277.39251040s; }
span.u7 { animation-delay: 2773.9251040s; }
span.u8 { animation-delay: 27739.251040s; }
output span.symbol {
display: inline-block;
}
@keyframes animate {
100% {
transform: translateY(-100%);
}
}
span.number::before {
content: "0\A 1\A 2\A 3\A 4\A 5\A 6\A 7\A 8\A 9";
animation: animate 10s steps(10, end) infinite;
position: absolute;
top: 0;
left: 0;
}
span.u0::before { animation-duration: 0.0022739251s; }
span.u1::before { animation-duration: 0.0277392510s; }
span.u2::before { animation-duration: 0.2773925104s; }
span.u3::before { animation-duration: 2.7739251040s; }
span.u4::before { animation-duration: 27.739251040s; }
span.u5::before { animation-duration: 277.39251040s; }
span.u6::before { animation-duration: 2773.9251040s; }
span.u7::before { animation-duration: 27739.251040s; }
span.u8::before { animation-duration: 277392.51040s; }
@keyframes pop {
100% {
transform: translate(0, -200%);
}
}
aside {
top: 0;
position: absolute;
background: #fca;
padding: 2vmin;
font-size: 2.5vw;
font-size: clamp(1rem, 2.5vw, 1.375rem);
max-width: 25vw;
max-width: clamp(100px, 25vw, 300px);
border-radius: 1vmin;
z-index: -1;
animation: pop 20s linear;
animation-fill-mode: forwards;
box-shadow: 0 0 2vmin rgba(0,0,0,0.25);
border: 1px solid rgba(0,0,0,0.125);
line-height: 1.25;
transform: translate(0, 100vh);
}
aside.color0 { background: #ffadad; }
aside.color1 { background: #ffd6a5; }
aside.color2 { background: #fdffb6; }
aside.color3 { background: #caffbf; }
aside.color4 { background: #beeeef; }
aside.color5 { background: #a0c4ff; }
aside.color6 { background: #bdb2ff; }
aside.color7 { background: #ffc6ff; }
aside.time0 { animation-timing-function: linear; }
aside.time1 { animation-timing-function: ease; }
aside.time2 { animation-timing-function: ease-in; }
aside.time3 { animation-timing-function: ease-out; }
aside.time4 { animation-timing-function: ease-in-out; }
aside.top0 { z-index: 1; }
aside.top1 { z-index: 3; }
footer {
position: absolute;
right: 0.5rem;
bottom: 0.5rem;
font-size: 0.875rem;
}
@media all and (min-width:500px) {
body {
--size: 2.5rem;
}
}
@media all and (min-width:750px) {
body {
--size: 3.5rem;
}
}
@media all and (min-width:1000px) {
body {
--size: 4.5rem;
}
}
@media all and (min-width:1200px) {
body {
--size: 5.5rem;
}
}
const output = document.querySelector("output");
const body = document.querySelector("body");
const numColors = 8;
const numTiming = 5;
const numTops = 3;
let amount = 0;
function createBubble(time, text) {
const left = Math.floor(Math.random() * 65);
const aside = document.createElement("aside");
aside.style.left = `${left + 5}vw`;
aside.className = `color${Math.floor(Math.random() * numColors)} time${Math.floor(Math.random() * numTiming)} top${Math.floor(Math.random() * numTops)}`;
aside.innerHTML = `<b>${time} seconds</b>:<br>${text}`;
body.append(aside);
}
const bubbles = [
{ time: 4, text: "more than a minimum wage worker... in a year" },
{ time: 9, text: "more than Amazon's lowest paid employee... in a year" },
{ time: 13, text: "more than the median yearly salary in the United States" },
{ time: 18, text: "more than the average yearly salary in the United States" },
{ time: 23, text: "more than his own yearly salary!" },
{ time: 28, text: "enough not to qualify for covid-19 stimulus checks" },
{ time: 32, text: "more than the average yearly salary of a Senior Software Developer" },
{ time: 38, text: "enough to buy a 'basic' Aston Martin Vantage" },
{ time: 48, text: "more than what a US Senator makes in a year" },
{ time: 55, text: "enough to buy a fully loaded Tesla Model S" },
{ time: 70, text: "enough to raise a child from birth to age 17" },
{ time: 80, text: "enough to buy a house for the median price in the USA" },
{ time: 89, text: "more than the yearly salary of 99% of the US population" },
{ time: 111, text: "more than what the US President makes in a year" },
{ time: 277, text: "enough to pay for the most expensive fishing lure ever" }
]
bubbles.forEach(function (el) {
setTimeout(`createBubble(${el.time}, "${el.text}")`, el.time * 1000);
});
Also see: Tab Triggers