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.
<!-- ABOUT LINK -->
<style> .what:hover { cursor: pointer; opacity: .75; } .what {display: block;width: 28px;height: 28px;position: fixed;right: 20px;bottom: 70px;background-size: 100% 100%; background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjNweCIgaGVpZ2h0PSIyM3B4IiB2aWV3Qm94PSIwIDAgMjMgMjMiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+ICAgICAgICA8dGl0bGU+U2xpY2UgMTwvdGl0bGU+ICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiAgICA8ZGVmcz48L2RlZnM+ICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPiAgICAgICAgPHBhdGggZD0iTTExLjUsMjIgQzE3LjI5ODk4OTksMjIgMjIsMTcuMjk4OTg5OSAyMiwxMS41IEMyMiw1LjcwMTAxMDEzIDE3LjI5ODk4OTksMSAxMS41LDEgQzUuNzAxMDEwMTMsMSAxLDUuNzAxMDEwMTMgMSwxMS41IEMxLDE3LjI5ODk4OTkgNS43MDEwMTAxMywyMiAxMS41LDIyIFoiIGlkPSJPdmFsIiBzdHJva2U9IiMzQTA1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Q0MTM4MTggMTAuNjcxODcwNSw3IDExLjU3MDMxMjUsNyBDMTIuNTE1NjI5Nyw3IDEzLjI2NzU3NTMsNy4yNDcwNjc4NCAxMy44MjYxNzE5LDcuNzQxMjEwOTQgQzE0LjM4NDc2ODQsOC4yMzUzNTQwMyAxNC42NjQwNjI1LDguODEwNTQzNTkgMTQuNjY0MDYyNSw5LjQ2Njc5Njg4IEMxNC42NjQwNjI1LDkuODMwMDc5OTQgMTQuNTYxNTI0NSwxMC4xNzM4MjY1IDE0LjM1NjQ0NTMsMTAuNDk4MDQ2OSBDMTQuMTUxMzY2MiwxMC44MjIyNjcyIDEzLjcxMjg5NCwxMS4yNjM2NjkxIDEzLjA0MTAxNTYsMTEuODIyMjY1NiBDMTIuNjkzMzU3NiwxMi4xMTEzMjk2IDEyLjQ3NzUzOTUsMTIuMzQzNzQ5MSAxMi4zOTM1NTQ3LDEyLjUxOTUzMTIgQzEyLjMwOTU2OTksMTIuNjk1MzEzNCAxMi4yNzE0ODQzLDEzLjAwOTc2MzQgMTIuMjc5Mjk2OSwxMy40NjI4OTA2IEwxMi4yNzkyOTY5LDEzLjQ2Mjg5MDYgWiBNMTAuNzg1MTU2MiwxNS42Nzc3MzQ0IEwxMC43ODUxNTYyLDE0LjAzMTI1IEwxMi40MzE2NDA2LDE0LjAzMTI1IEwxMi40MzE2NDA2LDE1LjY3NzczNDQgTDEwLjc4NTE1NjIsMTUuNjc3NzM0NCBaIiBpZD0iPyIgZmlsbD0iIzNBMDUzQSI+PC9wYXRoPiAgICA8L2c+PC9zdmc+);}</style><a href="http://mojs.io/tutorials/shape/" class="what" title="tutorial" target="_blank"></a>
<!-- ABOUT LINK -->
body, html {
padding: 0;
}
body {
background: rgba(241, 226, 215, 0.2);
background: #fff;
}
/* ADD CUSTOM SHAPES */
class Bubble extends mojs.CustomShape {
getShape () { return '<path d="M83.0657721,87.5048737 C74.252469,95.2810178 62.6770192,99.9991713 49.9995857,99.9991713 C22.385577,99.9991713 0,77.6135943 0,49.9995857 C0,22.385577 22.385577,0 49.9995857,0 C77.6135943,0 99.9991713,22.385577 99.9991713,49.9995857 C99.9991713,50.0248803 99.9991526,50.0501705 99.999115,50.0754564 L100,94.5453117 C100,99.9979302 96.8685022,101.290527 93.0045119,97.4313174 L83.0657721,87.5048737 Z"></path>'; }
getLength () { return 200; } // optional
}
class BubbleFlip extends mojs.CustomShape {
getShape () {
return '<path d="M16.9342279,87.5048737 C25.747531,95.2810178 37.3229808,99.9991713 50.0004143,99.9991713 C77.614423,99.9991713 100,77.6135943 100,49.9995857 C100,22.385577 77.614423,0 50.0004143,0 C22.3864057,0 0.000828659217,22.385577 0.000828659217,49.9995857 C0.000828659217,50.0248803 0.000847442255,50.0501705 0.000884995143,50.0754564 L0,94.5453117 C-5.64518814e-08,99.9979302 3.13149782,101.290527 6.99548809,97.4313174 L16.9342279,87.5048737 L16.9342279,87.5048737 Z"></path>'
}
}
class Check extends mojs.CustomShape {
getShape () {
return '<path d="M0,51.0412084 L30.5724856,79.9380913 C32.5759723,81.8317718 35.7778521,81.7755744 37.7145439,79.8221934 L100,17"></path>';
}
getLength () { return 175; }
}
mojs.addShape( 'bubble', Bubble ); // passing name and Bubble class
mojs.addShape( 'bubble-flip', BubbleFlip ); // passing name and BubbleFlip class
mojs.addShape( 'check', Check ); // passing name and Check class
const COLORS = {
purple: '#8A5CE6',
blue: '#42AFE3',
yellow: '#FADD4A',
red: '#FF6680'
}
const duration = 350,
delayStep = duration/3,
yShift = 10,
endAngle = 30;
let delay = 0;
// Common options for a bubble
const OPTS = {
shape: 'bubble',
scale: { 0 : 1 },
angle: { [-90] : endAngle, easing: 'cubic.out' },
y: { 0: -yShift },
easing: 'sin.out',
radius: 43,
duration
}
// bubble then options
const THEN_OPTS = {
y: 50,
angle: { to: -45, easing: 'cubic.in' },
scale: { to: 0, easing: 'quad.in' },
easing: 'sin.in',
}
// blue logo then options
const LOGO_THEN_OPTS = {
scale: 0,
delay: 1000
}
const purpleBubble = new mojs.Shape({
...OPTS,
fill: COLORS.purple,
origin: '100% 100%',
}).then({
...THEN_OPTS
});
const redBubble = new mojs.Shape({
...OPTS,
shape: 'bubble-flip',
fill: COLORS.red,
origin: '0% 100%',
delay: delay += delayStep,
x: 10, y: { [-55]: -55 - yShift},
angle: { 40 : -endAngle },
}).then({
...THEN_OPTS,
angle: { to: 90, easing: 'expo.in' }
});
const logoRectangle = new mojs.Shape({
shape: 'rect',
fill: COLORS.blue,
rx: 15,
radius: 74,
scale: { 0: 1 },
duration: 1.1*duration,
delay: 2.25*duration,
easing: 'quint.out',
}).then({
scale: 0,
angle: 90,
delay: 775,
easing: 'quad.in'
});
const whiteBubble = new mojs.Shape({
shape: 'bubble',
fill: 'white',
radius: 48,
scale: { 0: 1 },
duration: 1.25*duration,
delay: 2.25*duration,
easing: 'quint.out',
x: { [-25] : 0 },
y: { [-25] : 0 }
}).then({
scale: 0,
angle: 180,
delay: 600,
easing: 'sin.in'
});
const yellowBubble = new mojs.Shape({
...OPTS,
fill: COLORS.yellow,
origin: '100% 100%',
delay: delay += delayStep,
y: { [-85] : -85 - yShift },
x: 15,
angle: { [-30]: endAngle }
}).then({
...THEN_OPTS,
duration: 300,
y: 15
});
const blueCircle = new mojs.Shape({
shape: 'circle',
fill: COLORS.blue,
radius: 10,
scale: { 0 : 1 },
x: { [-25]: -55 },
y: { 0: -70 },
delay: duration/2 + 50,
duration: 1*duration,
easing: 'quad.out'
}).then({
x: -20,
y: 0,
delay: 50,
scale: { to: .65, easing: 'quad.in' },
duration: duration/1.75,
easing: 'cubic.in',
isShowEnd: false
});
const check = new mojs.Shape({
shape: 'check',
stroke: COLORS.blue,
fill: 'none',
radius: 18,
strokeWidth: 15,
x: 1, y: 2,
strokeLinecap: 'round',
strokeDasharray: '100%',
strokeDashoffset: { '100%': 0 },
delay: 2.5*duration - 50,
duration: 1.25*duration,
easing: 'quad.out'
}).then({
scale: 0,
duration: 1.35*duration,
delay: 450,
angle: 360,
easing: 'cubic.in'
});
const smallRect = new mojs.ShapeSwirl({
fill: COLORS.blue,
shape: 'rect',
radius: 10,
rx: 4,
scale: { 0: 1 },
duration: 1000,
easing: 'elastic.out',
opacity: { 1 : 0, easing: 'cubic.out' }
});
const timeline = new mojs.Timeline({ delay: 0 });
timeline
.add(
purpleBubble,
redBubble,
yellowBubble,
blueCircle,
logoRectangle,
whiteBubble,
check
).append( smallRect );
new MojsPlayer({ add: timeline, isPlaying: true, isRepeat: true });
Also see: Tab Triggers