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.
<div class="tangled"></div>
$test: #bada55;
$purple: #250c43;
$lavender: #7f6eb2;
$yellow: #f9f274;
div, div:before, div:after {
display: block;
content: '';
position: absolute;
box-sizing:border-box;
}
$body-w: 0vmin;
$body-h: 0vmin;
body {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background:
linear-gradient($purple, $purple),
}
div.tangled {
width: 70vmin;
height: 97vmin;
left: 6vmin;
display: flex;
margin: 0 auto;
position: relative;
background:
/** RAPUNZEL HAIR **/
radial-gradient(ellipse, $yellow .75vmin, transparent 1vmin) 36.25vmin 35.9vmin / 1.75vmin .75vmin no-repeat,
radial-gradient(ellipse, $yellow .75vmin, transparent 1vmin) 37.25vmin 35.9vmin / 1.5vmin 1.5vmin no-repeat,
/** RAPUNZEL **/
radial-gradient(ellipse, $purple 1vmin, transparent 1vmin) 36.5vmin 36.25vmin / 2vmin 2vmin no-repeat,
radial-gradient(ellipse, $purple 1vmin, transparent 1vmin) 37vmin 38vmin / 2vmin 4vmin no-repeat,
radial-gradient(ellipse, $purple 1.5vmin, transparent 1vmin) 36.5vmin 41.5vmin / 3vmin 2vmin no-repeat,
radial-gradient(ellipse, $purple 1.5vmin, transparent 1vmin) 36.5vmin 41.5vmin / 3vmin 2vmin no-repeat,
radial-gradient(ellipse at 90% 10%, transparent 5vmin, $purple 5vmin) 38.5vmin 36.25vmin / 5.5vmin 7vmin no-repeat,
/** TOWER **/
linear-gradient($purple 6vmin, transparent 1vmin) 49.15vmin 10vmin / .75vmin 15vmin no-repeat,
radial-gradient(ellipse, $purple 1.5vmin, transparent 1vmin) 48vmin 15vmin / 3vmin 3vmin no-repeat,
/* tower top*/ radial-gradient(ellipse at top left, transparent 15vmin, $purple 10vmin) 35.5vmin 5.5vmin / 14vmin 25vmin no-repeat,
radial-gradient(ellipse at top right, transparent 15vmin, $purple 10vmin) 49.5vmin 5.5vmin / 14vmin 25vmin no-repeat,
/* tower-top base */ radial-gradient(ellipse, $purple 12vmin, transparent 1vmin) 32vmin 29.25vmin / 35vmin 5vmin no-repeat,
radial-gradient(ellipse at top right, transparent 15vmin, $purple 10vmin) 36.75vmin 28vmin / 15vmin 2vmin no-repeat,
linear-gradient(-110deg, $purple 6vmin, transparent 1vmin) 31vmin 30vmin / 12vmin 3vmin no-repeat,
/* balcony */linear-gradient(-110deg, $purple 6vmin, transparent 1vmin) 29.5vmin 43.25vmin / 12vmin 2vmin no-repeat,
/* tower-top base */ radial-gradient(ellipse, $purple 12vmin, transparent 1vmin) 39.5vmin 30vmin / 20vmin 18vmin no-repeat,
/* tower-top base */ radial-gradient(ellipse, $purple 8vmin, transparent 1vmin) 42vmin 45vmin / 15vmin 5vmin no-repeat,
/* long tower */ linear-gradient(87deg, $purple 6vmin, transparent 1vmin) 49vmin 50vmin / 12vmin 40vmin no-repeat,
linear-gradient(-87deg, $purple 6vmin, transparent 1vmin) 38vmin 50vmin / 12vmin 40vmin no-repeat,
/** CITY **/
/* right towertops */ linear-gradient(-75deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 8vmin) calc(#{$body-h} + 38vmin) / 2vmin 5vmin no-repeat,
linear-gradient(75deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 10vmin) calc(#{$body-h} + 38vmin) / 2vmin 5vmin no-repeat,
linear-gradient(-55deg, darken($lavender, 20%) 1.5vmin, transparent 1vmin) calc(#{$body-w} + 4.5vmin) calc(#{$body-h} + 43vmin) / 3vmin 5vmin no-repeat,
linear-gradient(55deg, darken($lavender, 20%) 1.5vmin, transparent 1vmin) calc(#{$body-w} + 7.5vmin) calc(#{$body-h} + 43vmin) / 3vmin 5vmin no-repeat,
/* right tower */ linear-gradient(darken($lavender, 20%) 5vmin, transparent 1vmin) calc(#{$body-w} + 9.5vmin) calc(#{$body-h} + 43vmin) / 2vmin 20vmin no-repeat,
linear-gradient(90deg, darken($lavender, 20%) 4vmin, transparent 1vmin) calc(#{$body-w} + 6vmin) calc(#{$body-h} + 48vmin) / 10vmin 4vmin no-repeat,
/* right side */ linear-gradient(29deg, darken($lavender, 20%) 10.5vmin, transparent 1vmin) calc(#{$body-w} + 20vmin) calc(#{$body-h} + 20.5vmin) / 22vmin 35vmin no-repeat,
/* right towertops */
linear-gradient(-65deg, darken($lavender, 20%) 1.5vmin, transparent 1vmin) calc(#{$body-w} + 13vmin) calc(#{$body-h} + 35.5vmin) / 3vmin 5vmin no-repeat,
linear-gradient(65deg, darken($lavender, 20%) 1.5vmin, transparent 1vmin) calc(#{$body-w} + 16vmin) calc(#{$body-h} + 35.5vmin) / 3vmin 5vmin no-repeat,
linear-gradient(-65deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 16vmin) calc(#{$body-h} + 35.5vmin) / 2vmin 5vmin no-repeat,
linear-gradient(65deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 18.5vmin) calc(#{$body-h} + 35.5vmin) / 2vmin 5vmin no-repeat,
linear-gradient(-65deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 18.25vmin) calc(#{$body-h} + 28vmin) / 2vmin 5vmin no-repeat,
linear-gradient(65deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 20.25vmin) calc(#{$body-h} + 28vmin) / 2vmin 5vmin no-repeat,
linear-gradient(-65deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 20vmin) calc(#{$body-h} + 33.25vmin) / 2vmin 5vmin no-repeat,
linear-gradient(65deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 22vmin) calc(#{$body-h} + 33.25vmin) / 2vmin 5vmin no-repeat,
/* right tower */ linear-gradient(darken($lavender, 20%) 8vmin, transparent 1vmin) calc(#{$body-w} + 15vmin) calc(#{$body-h} + 40vmin) / 8vmin 24vmin no-repeat,
linear-gradient(darken($lavender, 20%) 6vmin, transparent 1vmin) calc(#{$body-w} + 17.75vmin) calc(#{$body-h} + 36vmin) / 1.5vmin 14vmin no-repeat,
linear-gradient(darken($lavender, 20%) 9vmin, transparent 1vmin) calc(#{$body-w} + 19.5vmin) calc(#{$body-h} + 32vmin) / 1.5vmin 18vmin no-repeat,
linear-gradient(darken($lavender, 20%) 6vmin, transparent 1vmin) calc(#{$body-w} + 21.25vmin) calc(#{$body-h} + 38vmin) / 1.5vmin 14vmin no-repeat,
/* center side */ linear-gradient(-80deg, darken($lavender, 20%) 11vmin, transparent 1vmin) calc(#{$body-w} + 2vmin) calc(#{$body-h} + 41.5vmin) / 18vmin 14vmin no-repeat,
/* left towertops */
linear-gradient(-65deg, darken($lavender, 20%) 1.5vmin, transparent 1vmin) calc(#{$body-w} + 23vmin) calc(#{$body-h} + 38.5vmin) / 3vmin 5vmin no-repeat,
linear-gradient(65deg, darken($lavender, 20%) 1.5vmin, transparent 1vmin) calc(#{$body-w} + 26vmin) calc(#{$body-h} + 38.5vmin) / 3vmin 5vmin no-repeat,
linear-gradient(-35deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 28.75vmin) calc(#{$body-h} + 41vmin) / 2vmin 5vmin no-repeat,
linear-gradient(35deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 30.75vmin) calc(#{$body-h} + 41vmin) / 2vmin 5vmin no-repeat,
linear-gradient(-75deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 31.5vmin) calc(#{$body-h} + 43vmin) / 2vmin 5vmin no-repeat,
linear-gradient(75deg, darken($lavender, 20%) 1vmin, transparent 1vmin) calc(#{$body-w} + 33.5vmin) calc(#{$body-h} + 43vmin) / 2vmin 5vmin no-repeat,
/* left towers */
linear-gradient(darken($lavender, 20%) 6vmin, transparent 1vmin) calc(#{$body-w} + 25vmin) calc(#{$body-h} + 43vmin) / 2vmin 14vmin no-repeat,
linear-gradient(darken($lavender, 20%) 6vmin, transparent 1vmin) calc(#{$body-w} + 29.25vmin) calc(#{$body-h} + 45vmin) / 3vmin 14vmin no-repeat,
linear-gradient(darken($lavender, 20%) 6vmin, transparent 1vmin) calc(#{$body-w} + 32.5vmin) calc(#{$body-h} + 47.5vmin) / 2vmin 14vmin no-repeat,
/* left side */ linear-gradient(-35deg, darken($lavender, 20%) 12vmin, transparent 1vmin) calc(#{$body-w} + 2vmin) calc(#{$body-h} + 25.5vmin) / 18vmin 30vmin no-repeat,
/** BACKGROUND **/
/* left side rocks */ radial-gradient(ellipse, $purple 10vmin, transparent 1vmin) calc(#{$body-w} - 11vmin) calc(#{$body-h} + 60vmin) / 20vmin 15vmin no-repeat,
radial-gradient(ellipse, $purple 10vmin, transparent 1vmin) calc(#{$body-w} - 8vmin) calc(#{$body-h} + 70vmin) / 20vmin 5vmin no-repeat,
radial-gradient(ellipse, $purple 10vmin, transparent 1vmin) calc(#{$body-w} - 8vmin) calc(#{$body-h} + 70vmin) / 20vmin 12vmin no-repeat,
radial-gradient(ellipse, $purple 10vmin, transparent 1vmin) calc(#{$body-w} - 4vmin) calc(#{$body-h} + 76vmin) / 20vmin 7vmin no-repeat,
radial-gradient(ellipse, $purple 10vmin, transparent 1vmin) calc(#{$body-w} - 4vmin) calc(#{$body-h} + 79vmin) / 20vmin 23vmin no-repeat,
/* bottom rocks */ radial-gradient(ellipse, $purple 15vmin, transparent 1vmin) calc(#{$body-w} - 1vmin) calc(#{$body-h} + 88vmin) / 30vmin 13vmin no-repeat,
radial-gradient(ellipse, $purple 5vmin, transparent 1vmin) calc(#{$body-w} + 25vmin) calc(#{$body-h} + 85vmin) / 12vmin 13vmin no-repeat,
radial-gradient(ellipse, $purple 6.5vmin, transparent 1vmin) calc(#{$body-w} + 30vmin) calc(#{$body-h} + 80vmin) / 18vmin 25vmin no-repeat,
radial-gradient(ellipse, $purple 15vmin, transparent 1vmin) calc(#{$body-w} + 40vmin) calc(#{$body-h} + 82vmin) / 30vmin 13vmin no-repeat,
/* right rocks */ radial-gradient(ellipse, $purple 6.5vmin, transparent 1vmin) calc(#{$body-w} + 55vmin) calc(#{$body-h} + 70vmin) / 16vmin 30vmin no-repeat,
/* NE curve */ radial-gradient(ellipse at bottom left, transparent 20vmin, $purple 20vmin) calc(#{$body-w} + 44.25vmin) calc(#{$body-h} + 1vmin) / 25vmin 20vmin no-repeat,
/* background */ linear-gradient(180deg, $lavender 50vmin, darken($lavender, 10%) 50vmin, darken($lavender, 10%) 90vmin, transparent 90vmin) calc(#{$body-w} + 2vmin) calc(#{$body-h} + 5vmin) / 62.25vmin 86vmin no-repeat,
}
div.tangled:after {
width: 50vmin;
left: 0vmin;
top: 0vmin;
height: 55vmin;
transform-origin: 35% 100%;
transform: scale(0.5) translate(-10vmin, -10vmin);
animation: lanterns 20s ease-in-out 1;
background:
/** BIG LANTERNS **/
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1.25vmin, transparent 1.65vmin) 30vmin 27vmin / 2.5vmin 4.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1.25vmin, transparent 1.65vmin) 20vmin 7vmin / 2.5vmin 4.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1.25vmin, transparent 1.65vmin) 24vmin 13vmin / 2.5vmin 4.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1.25vmin, transparent 1.65vmin) 6vmin 18vmin / 2.5vmin 4.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1.25vmin, transparent 1.65vmin) 12vmin 23vmin / 2.5vmin 4.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1.25vmin, transparent 1.65vmin) 6vmin 33vmin / 2.5vmin 4.5vmin no-repeat,
/** MID LANTERNS **/
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1vmin, transparent 1.25vmin) 5vmin 27vmin / 2vmin 4vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1vmin, transparent 1.25vmin) 15vmin 12vmin / 2vmin 4vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1vmin, transparent 1.25vmin) 29vmin 4vmin / 2vmin 4vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1vmin, transparent 1.25vmin) 9vmin 14vmin / 2vmin 4vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1vmin, transparent 1.25vmin) 20vmin 16vmin / 2vmin 4vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1vmin, transparent 1.25vmin) 18vmin 24vmin / 2vmin 4vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 10%), darken($yellow, 30%) 1vmin, transparent 1.25vmin) 33vmin 7vmin / 2vmin 4vmin no-repeat,
/** SMALL LANTERNS **/
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 25vmin 32vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 15vmin 34vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 11vmin 37vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 5vmin 42vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 29vmin 41vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 22vmin 25vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 15vmin 22vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 3vmin 17vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 33vmin 17vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 30vmin 27vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 10vmin 27vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 0vmin 23vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 35vmin 23vmin / 1.25vmin 2.5vmin no-repeat,
radial-gradient(ellipse, lighten($yellow, 0%), darken($yellow, 40%) .75vmin, transparent .75vmin) 28vmin 21vmin / 1.25vmin 2.5vmin no-repeat,
}
div.tangled:before {
width: 30vmin;
left: 20vmin;
top: 36vmin;
height: 60vmin;
transform-origin: 50% 0;
animation: hair 7s ease-in-out infinite;
background:
radial-gradient(ellipse at -10% 10%, transparent 2.75vmin, $yellow 2.75vmin, $yellow 3.5vmin, transparent 3.5vmin) 15.75vmin 0vmin / 6vmin 10vmin no-repeat,
radial-gradient(ellipse at 120% 90%, transparent 2.75vmin, $yellow 2.75vmin, $yellow 3.5vmin, transparent 3.5vmin) 13vmin 4.25vmin / 3vmin 6vmin no-repeat,
radial-gradient(ellipse at 110% 0%, transparent 2.75vmin, $yellow 2.75vmin, $yellow 3.5vmin, transparent 3.5vmin) 13.25vmin 9.75vmin / 3vmin 6vmin no-repeat,
radial-gradient(ellipse at -20% 90%, transparent 2.75vmin, $yellow 2.75vmin, $yellow 3.5vmin, transparent 3.5vmin) 15.75vmin 14.25vmin / 3vmin 6vmin no-repeat,
radial-gradient(ellipse at -10% 10%, transparent 2.75vmin, $yellow 2.75vmin, $yellow 3.5vmin, transparent 3.5vmin) 15.75vmin 19.75vmin / 6vmin 14vmin no-repeat,
radial-gradient(ellipse at 120% 90%, transparent 2.75vmin, $yellow 2.75vmin, $yellow 3.5vmin, transparent 3.5vmin) 13vmin 25.75vmin / 3vmin 8vmin no-repeat,
radial-gradient(ellipse at 110% 0%, transparent 2.75vmin, $yellow 2.75vmin, $yellow 3.5vmin, transparent 3.5vmin) 13.25vmin 33vmin / 3vmin 11vmin no-repeat,
}
@keyframes hair {
0%, 100% {
transform: rotate(1deg);
}
50% {
transform: rotate(-1deg);
}
}
@keyframes lanterns {
0% {
}
100% {
transform: scale(0.75) translate(10vmin, -10vmin);
}
}
/* Greg Robleto
cssartstudio.com */
/* Inspired by Repunzel by Olga Nazarova found on iStockPhoto */
Also see: Tab Triggers