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.
<template>
<div class="avocado">
<svg viewBox="0 0 135 178">
<g class="arms" fill="none" stroke="#000" stroke-linecap="round" stroke-width="4">
<path d="M 30.971627,77.044969 C 1.8442515,59.644207 10.922912,43 10.922912,43"/>
<path d="M 104.95126,77.044969 C 134.07865,59.644207 125,43 125,43"/>
</g>
<g class="feets" fill="none" stroke="#000" stroke-linecap="round" stroke-width="4">
<path d="m 75.973727,140.56989 c 5.91069,24.01215 -1.10825,35.4641 -1.10825,35.4641 h 11.08253"/>
<path d="m 54.886437,140.56989 c -5.91069,24.01215 1.10825,35.4641 1.10825,35.4641 h -11.08253"/>
</g>
<g class="body">
<path class="d" fill="none" d="m 129.0419,111.78105 c -3.47383,6.01685 -56.212884,0 -63.160544,0 -6.947659,0 -59.6867121,6.01685 -63.1605421,0 C -0.75301594,105.7642 30.827254,63.099265 34.301084,57.082415 37.774914,51.065566 58.933696,2.3837816 65.881356,2.3837814 c 6.947659,-2e-7 28.10644,48.6817826 31.580269,54.6986326 3.473835,6.01685 35.054105,48.681786 31.580275,54.698636 z"/>
<path class="outer" fill="#2a670c" d="M65 5a40 54 0 0 0-40 54 40 54 0 0 0 0 9 50 50 0 0 0-9 30 50 50 0 0 0 49 49 50 50 0 0 0 50-49 50 50 0 0 0-10-30 40 54 0 0 0 1-9A40 54 0 0 0 65 5z"/>
<path class="inner" fill="#c1e20c" d="M65 12a36 48 0 0 0-36 48 36 48 0 0 0 1 8 44 44 0 0 0-9 26 44 44 0 0 0 44 44 44 44 0 0 0 45-44 44 44 0 0 0-9-26 36 48 0 0 0 0-8 36 48 0 0 0-36-48z"/>
</g>
<g class="seed">
<circle cx="66" cy="93" r="20" fill="#452c0c"/>
<path fill="#FFF2" d="M107-65a15 15 0 0 1-7 13 15 15 0 0 1-15 0 15 15 0 0 1-7-13" transform="rotate(90)"/>
</g>
<g class="face">
<g class="eye izq">
<circle cx="58" cy="42" r="6"/>
<circle cx="56" cy="41" r="3" fill="#fff"/>
</g>
<g class="eye der">
<circle cx="73" cy="42" r="6"/>
<circle cx="72" cy="41" r="3" fill="#fff"/>
</g>
<path d="M73 53a8 8 0 0 1-4 7 8 8 0 0 1-8 0 8 8 0 0 1-4-7"/>
</g>
</svg>
</div>
</template>
<div class="grid"></div>
<div class="waves"></div>
<div class="data">
<h1>Avocado</h1>
<div class="music">🎵</div>
<h2>#Codevember</h2>
<a class="ghost" href="https://twitter.com/Manz" target="_blank">Code by Manz</a>
<a class="ghost" href="https://soundcloud.com/tomdalips/tom-da-lips-avocado-free-download" target="_blank">Music by Tom Da Lips</a>
</div>
<iframe style="display:none" width="100%" height="300" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/324580306&color=%23ff5500&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>
@import url('https://fonts.googleapis.com/css?family=Montserrat:400,600,800');
.data {
position:relative;
z-index:0;
text-align:center;
width:400px;
margin:auto;
padding:20px;
}
h1, h2, .ghost {
font-family:Montserrat;
font-weight:600;
margin:0;
}
h1 {
font-weight:800;
letter-spacing:-2px;
font-size:64px;
color:#444;
}
h2 {
font-size:24px;
color:#222;
}
.ghost {
font-weight:400;
font-size:15px;
color:#000;
display:inline-block;
margin:8px 2px;
padding:8px;
border:1px solid #2a670c;
text-decoration:none;
}
a.ghost:hover {
transition:all .5s linear;
background:rgba(50,50,50, .2);
border-color:#000;
color:#000;
}
body {
background:#e4ff93;
display:flex;
justify-content:center;
align-items:center;
overflow:hidden;
animation:ambient 4s ease alternate infinite;
}
@keyframes ambient {
0% { background:#e4ff93 }
50% { background:#888 }
100% { background:#98ff93 }
}
.grid {
display: grid;
grid-template-columns: 30vw 30vw 30vw;
justify-items:center;
align-items:end;
position:absolute;
bottom:50px;
pointer-events:none;
z-index:1;
}
.grid .avocado:nth-child(2) svg { width:250px; z-index:5 }
.avocado {
border-bottom:1px solid #777;
pointer-events:none;
}
.avocado .body,
.avocado .face,
.avocado .arms {
transition:all .5s ease;
}
.avocado svg {
width:175px;
transform-origin:50% 100%;
animation:dancing .5s linear alternate infinite;
position:relative;
top:5px;
pointer-events:none;
}
.avocado.super .d {
transform:translateY(10px);
fill:#b2132c;
}
.avocado.back {
transform-origin:50% 100%;
animation:dancing .5s linear alternate infinite;
}
.avocado.back .inner,
.avocado.back .seed,
.avocado.back .face {
opacity:0;
}
.dorito .inner,
.dorito .outer,
.dorito .seed {
opacity:0;
}
.dorito .body,
.dorito .arms,
.dorito .face {
transform:translateY(35px);
}
.dorito .d {
fill:#e3c02c;
}
@keyframes dancing {
0% { transform:skew(-1deg) scaleY(1.025) scaleX(1) }
50% { transform:skew(0) scaleY(.999) scaleX(1) }
100% { transform:skew(1deg) scaleY(1.025) scaleX(1) }
}
@keyframes assdancing {
0% { transform:skew(-2deg) scaleY(1.025) scaleX(.9) }
50% { transform:skew(0) scaleY(.999) scaleX(1) }
100% { transform:skew(2deg) scaleY(1.025) scaleX(1.1) }
}
.avocado .eye {
animation:blink 4s steps(2) infinite;
}
@keyframes blink {
0%, 49%, 52%, 100% { opacity:1 }
50% { opacity:0 }
}
.music {
position:absolute;
top:15px;
right:20px;
color:#000;
font-size:32px;
animation:movenote .5s ease alternate infinite;
z-index:10;
}
@keyframes movenote {
0% { transform:translate(-10px, -5px) }
50% { transform:translate(0, 0) }
100% { transform:translate(10px, -5px) }
}
.waves {
width:100vw;
height:350px;
position:absolute;
bottom:52px;
z-index:-1;
display:flex;
justify-content:center;
align-items:flex-end;
}
.bar {
width:10vw;
height:100%;
background:#FFF;
margin:0 5px;
transition:height .15s ease;
}
let avocado = document.querySelector('template');
let grid = document.querySelector('.grid');
let waves = document.querySelector('.waves');
let options = ['avocado', 'avocado back', 'super avocado', 'avocado dorito'];
for (let i = 0; i < 3; i++)
grid.appendChild(avocado.content.cloneNode(true));
for (let i = 0; i < 10; i++) {
let bar = document.createElement('div');
bar.className = 'bar';
waves.appendChild(bar);
}
let avocados = document.querySelectorAll('.avocado');
let bars = document.querySelectorAll('.bar');
function change() {
for (let i = 0; i < avocados.length; i++)
avocados[i].className = options[~~(Math.random() * options.length)];
}
function updateBars() {
for (let i = 0; i < bars.length; i++)
bars[i].style.height = ~~(Math.random() * 100) + '%';
}
setInterval(change, 3000);
setInterval(updateBars, 100 + ~~(Math.random() * 100));
Also see: Tab Triggers