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.
<svg class='scene' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1258 1186" clip-rule="evenodd" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
<g class='rocket'>
<g class='rocket__stream'>
<path d="M745 608h6v263h-6z" />
<path d="M761 608h6v263h-6z" />
<path d="M755 608h6v263h-6z" />
<path d="M749 608h6v263h-6z" />
<path d="M778 608h6v263h-6z" />
<path d="M772 608h6v263h-6z" />
<path d="M767 608h6v263h-6z" />
</g>
<g class='rocket__bubbles'>
<path d="M717 869a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M704 873a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M736 863a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M774 865a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M720 884a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M719 876a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M765 879a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M738 884a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M721 851a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M716 876a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M747 881a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M764 882a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M766 852a25 25 0 1150 0 25 25 0 01-50 0z" />
<path d="M735 847a25 25 0 1150 0 25 25 0 01-50 0z" />
</g>
<g class='rocket__body'>
<path d="M743 602h43v9h-43z"/>
<path d="M776 601h10v10h-10z"/>
<path d="M764 442c-17 0-31 15-31 33v129h63V475c0-18-14-33-32-33z"/>
<path d="M764 442c18 0 32 15 32 33v129h-8V475c0-16-12-30-27-32l3-1z"/>
</g>
</g>
<g class='kitty'>
<g class='kitty__tails'>
<path class='kitty__tail' d="M698 618c-2 16-9 38-6 53 3 12 14 22 15 35 1 16-6 32-8 46" fill="none" stroke-width="20"/>
<path class='kitty__tail' d="M701 619c2 16 9 38 5 53-2 12-13 21-14 34-2 17 6 33 7 47" fill="none" stroke-width="20"/>
</g>
<g class='kitty__leg kitty__leg--right'>
<path class='kitty__light' d="M670 588c8 0 15 7 15 15v93c0 8-7 15-15 15s-14-7-14-15v-93c0-8 6-15 14-15z"/>
<path class='kitty__dark' d="M677 590l2 7v94c0 8-6 14-14 14l-7-2c2 5 7 8 12 8 8 0 15-7 15-15v-93c0-6-3-10-8-13z"/>
</g>
<g class='kitty__leg kitty__leg--left'>
<path class='kitty__light' d="M730 591c8 0 14 6 14 14v94c0 8-6 14-14 14s-15-6-15-14v-94c0-8 7-14 15-14z"/>
<path class='kitty__dark' d="M737 593l2 6v94c0 8-7 15-15 15-3 0-5-1-7-3 2 5 7 8 13 8 8 0 14-6 14-14v-94c0-5-3-10-7-12z"/>
</g>
<g class='kitty__body'>
<path class='kitty__light' d="M699 446c27 0 49 22 49 48v97c0 27-22 48-49 48s-49-21-49-48v-97c0-26 22-48 49-48z"/>
<path class='kitty__dark' d="M699 639c27 0 49-22 49-48l1-98c-1-15-10-28-21-37 5 8 9 17 9 27v97c1 27-21 48-48 49-12 0-22-4-30-10 9 12 24 20 40 20z"/>
</g>
<path class='rocket__strap' d="M652 509l91-11c5-1 9 3 10 7v1c0 5-3 9-8 10l-91 11c-5 0-9-3-10-8v-1c0-5 3-9 8-9z"/>
<g class='kitty__arm kitty__arm--right'>
<path class='kitty__light' d="M734 468c8 2 13 10 11 18l-20 91c-2 8-10 13-18 11s-13-10-11-17l21-92c2-8 9-13 17-11z"/>
<path class='kitty__dark' d="M741 471v8l-21 91c-1 8-9 13-17 11l-7-4c2 5 6 10 11 11 8 2 16-3 18-11l21-92c1-5-1-10-5-14z"/>
</g>
<g class='kitty__arm kitty__arm--left'>
<path class='kitty__light' d="M659 475c8 2 13 10 11 18l-22 91c-2 8-10 13-18 11s-13-10-11-18l23-91c1-8 9-13 17-11z"/>
<path class='kitty__dark' d="M665 479l1 7-23 91c-1 8-9 13-17 11l-7-4c2 5 6 9 11 11 8 2 16-3 18-11l22-91c1-5-1-10-5-14z"/>
</g>
<g class='kitty__head'>
<g class='kitty__stroke' fill="none" stroke-width="5">
<path d="M548 467c-18 10-38 13-54 26"/>
<path d="M560 485l-48 31"/>
<path d="M574 495c-9 7-14 19-17 30"/>
<path d="M745 351c7-13 31-22 43-30"/>
<path d="M757 374c11-8 24-19 38-12"/>
<path d="M760 390c10-6 38 4 47 9"/>
</g>
<path class='kitty__light' d="M652 326c4-107 90-53 73 8 48 34 64 104-5 155-94 71-188 9-181-68-37-57-22-143 46-67"/>
<path class='kitty__muzzle' d="M616 454c-7-14 5-34 28-46 22-11 46-9 53 5s-5 35-27 46c-23 12-47 9-54-5z"/>
<g class='kitty__eye kitty__eye--left'>
<path class='kitty__stroke kitty__fill' d="M565 444a7 7 0 1112-8 7 7 0 01-12 8z" stroke-width="5"/>
</g>
<g class='kitty__eye kitty__eye--right'>
<path class='kitty__stroke kitty__fill' d="M712 377a7 7 0 1112-7 7 7 0 01-12 7z" stroke-width="5"/>
</g>
<path class='kitty__light' d="M570 369c9-8 15-20 25-27 22-15 47-18 72-16" />
<path class='kitty__dark-stroke' d="M690 287c-18-22-28 18-25 30v3" fill="none" stroke-width="4"/>
<path class='kitty__dark-stroke' d="M536 352c-6-8 2-21 11-15 6 5 12 9 17 15 1 2 7 10 8 9" fill="none" stroke-width="4"/>
<path class='kitty__stroke' d="M631 451c19 7 15-12 26-15 4-2 10 3 16 0 2-2 14-11 11-13" fill="none" stroke-width="4"/>
<path class='kitty__stroke' d="M644 426c-1-3 1-5 4-7 3-1 7-1 8 1s-1 5-4 7c-4 1-7 1-8-1z" stroke-width="2"/>
<path class='kitty__dark' d="M695 267c14 12 23 35 17 59 47 34 63 104-6 155-47 36-94 38-129 21 35 25 89 28 143-13 69-51 53-121 5-155 9-31-10-61-30-67z"/>
</g>
</g>
<g class='stars'>
<path d="M908 657l-10-9-13 4 5-12-8-11h13l8-10 4 13 13 4-11 7z" fill-rule="nonzero"/>
<path d="M1128 89l-10-8-13 3 5-12-8-11 13 1 8-11 4 13 13 4-11 8z" fill-rule="nonzero"/>
<path d="M296 287l-10-9-13 4 5-12-8-11h13l8-10 4 13 12 4-11 7z" fill-rule="nonzero"/>
<path d="M188 991l-10-8-13 4 5-13-8-11 13 1 8-11 4 13 13 4-11 8z" fill-rule="nonzero"/>
<path d="M1227 1137l-10-9-13 4 5-12-8-11h13l8-10 4 13 12 4-11 7z" fill-rule="nonzero"/>
</g>
</svg>
*
box-sizing border-box
body
--hue 12
--star hsl(42, 91%, 65%)
--bg hsl(0, 0%, 15%)
--strap hsl(0, 0%, 13%)
--red hsl(4, 80%, 65%)
--orange hsl(24, 80%, 65%)
--lime hsl(64, 80%, 65%)
--green hsl(104, 80%, 65%)
--turquoise hsl(184, 80%, 65%)
--purple hsl(244, 80%, 65%)
--indigo hsl(264, 80%, 65%)
--violet hsl(324, 80%, 65%)
--tail 'hsl(%s, 27%, 62%)' % var(--hue)
--stroke hsl(0, 0%, 10%)
--muzzle 'hsl(%s, 43%, 89%)' % var(--hue)
--dark 'hsl(%s, 33%, 67%)' % var(--hue)
--light 'hsl(%s, 65%, 79%)' % var(--hue)
--strap hsl(0, 0%, 20%)
background var(--bg)
display flex
align-items center
justify-content center
min-height 100vh
overflow hidden
svg
height 100vmin
display none
.stars
path
fill var(--star)
.kitty
&__light
fill var(--light)
&__dark
fill var(--dark)
&__dark-stroke
stroke var(--dark)
&__stroke
stroke var(--stroke)
&__fill
fill var(--stroke)
&__muzzle
fill var(--muzzle)
&__tail
stroke var(--tail)
.rocket
&__strap
fill var(--strap)
&__body
path:nth-of-type(1)
fill hsl(0, 0%, 65%)
path:nth-of-type(2)
fill hsl(0, 0%, 20%)
path:nth-of-type(3)
fill hsl(0, 0%, 85%)
path:nth-of-type(4)
fill hsl(0, 0%, 30%)
&__stream
&__bubbles
path
&:nth-of-type(1)
&:nth-of-type(8)
fill var(--red)
&:nth-of-type(2)
&:nth-of-type(9)
fill var(--orange)
&:nth-of-type(3)
&:nth-of-type(10)
fill var(--lime)
&:nth-of-type(4)
&:nth-of-type(11)
fill var(--green)
&:nth-of-type(5)
&:nth-of-type(12)
fill var(--turquoise)
&:nth-of-type(6)
&:nth-of-type(13)
fill var(--purple)
&:nth-of-type(7)
&:nth-of-type(14)
fill var(--indigo)
&:nth-of-type(8)
&:nth-of-type(15)
fill var(--violet)
const {
gsap: {
set,
to,
timeline,
utils: { random },
},
} = window
const TAILS = [...document.querySelectorAll('.kitty__tail')]
const STARS = [...document.querySelectorAll('.stars path')]
const BUBBLES = [...document.querySelectorAll('.rocket__bubbles path')]
const EYES = [...document.querySelectorAll('.kitty__eye')]
set('.scene', { display: 'block' })
set(TAILS[1], { display: 'none' })
to(TAILS[0], {
duration: 0.1,
ease: 'none',
yoyo: true,
repeat: -1,
morphSVG: TAILS[1],
})
set('.stars path', {
y: -1185,
transformOrigin: '50% 50%',
rotation: 'random(0, 360)',
scale: 'random(0.2, 1.2)'
})
STARS.forEach(star =>
to(star, {
repeat: -1,
duration: 'random(4, 10)',
delay: () => 'random(-10, -5)',
y: 1185,
ease: 'none',
})
)
set(BUBBLES, { scale: 0, transformOrigin: '50% 50%' })
BUBBLES.forEach(bubble =>
timeline({ repeat: -1, yoyo: true })
.to(bubble, {
duration: 0.5,
scale: 2.5,
})
.to(
bubble,
{
duration: 0.2,
opacity: 0,
},
'>-0.2'
)
.seek(Math.random())
)
set(EYES, { transformOrigin: '50% 50%', rotate: -25 })
const blink = () => {
const delay = random(2, 5)
to(EYES, {
delay,
duration: 0.1,
repeat: 1,
yoyo: true,
scaleY: 0,
onComplete: () => blink(),
})
}
blink()
to('.kitty__head', {
repeat: -1,
yoyo: true,
rotate: 2,
duration: 0.1,
transformOrigin: '75% 75%',
})
to('.kitty__arm', {
repeat: -1,
yoyo: true,
rotate: 2,
duration: 0.1,
transformOrigin: '75% 15%',
})
to('.kitty__leg--left', {
repeat: -1,
yoyo: true,
rotate: 2,
duration: 0.1,
transformOrigin: '50% 5%',
})
to('.kitty__leg--right', {
repeat: -1,
yoyo: true,
rotate: -2,
duration: 0.1,
transformOrigin: '50% 5%',
})
const PARTY = timeline({
paused: true,
}).fromTo(
document.body,
{
'--hue': 0,
},
{
'--hue': 360,
repeat: 10,
ease: 'none',
}
)
// HMM not sure??
// to('.kitty__arm--right', {
// repeat: -1,
// yoyo: true,
// rotate: -2,
// duration: 0.1,
// transformOrigin: '75% 25%',
// })
// Yeah, that's it...
// Why are you still going?
// You wouldn't want to party would you?
// No, stop, honestly, this party isn't even that cool!
const keys = []
const shouldWeParty = e => {
keys.push(e.key)
if (
keys
.slice(keys.length - 5, keys.length)
.join('')
.toLowerCase() === 'party'
) {
// Let's party
keys.length = 0
PARTY.restart()
}
}
window.addEventListener('keyup', shouldWeParty)
Also see: Tab Triggers