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="cloud">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div class="balloon"></div>
<figure class="madeline-container">
<div class="body">
<div class="body__leg-l"></div>
<div class="body__leg-r"></div>
</div>
<div class="head">
<div class="head__hat"></div>
<div class="head__hair"></div>
<div class="head__face"></div>
<div class="head__hair--fringe"></div>
</div>
<div class="arm__r"></div>
<div class="arm__l"></div>
</figure>
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
/* --- Colours --- */
$n: #010152;
$o: #d25317;
$y: #f7e957;
$skin: #efdebd;
$pr: #d8b9d7;
$pk: #ffc0cb;
$r: #dd2602;
$w: #fff;
$b: #000;
$t: transparent;
@mixin pseduo-div( $w, $h, $c ) {
content: '';
width: $w;
height: $h;
display: block;
position: absolute;
background-color: $c;
}
@mixin w-h ( $w, $h ) {
width: $w;
height: $h;
}
/* --- Styles --- */
body {
margin: 0;
background: linear-gradient( $pr 50%, $pk );
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
position: relative;
}
.cloud {
div {
position: absolute;
will-change: margin-top;
&:nth-child( 1 ) {
@include w-h ( 36vmin, 25vmin );
top: 35%;
left: 3%;
opacity: 0.6;
background:
radial-gradient( 1vmin 1vmin at 16% 53%, $w 4vmin, $t 4.4vmin ),
radial-gradient( 0.8vmin 1vmin at 33% 51%, $w 6vmin, $t 6.4vmin ),
radial-gradient( 1.5vmin 1vmin at 57% 30%, $w 7vmin, $t 7.5vmin ),
radial-gradient( 1.2vmin 1vmin at 79% 36%, $w 3vmin, $t 3.4vmin ),
radial-gradient( 2vmin 1.5vmin at 84% 55%, $w 5vmin, $t 5.5vmin ),
radial-gradient( 2vmin 1.5vmin at 78% 72%, $w 4vmin, $t 4.5vmin ),
radial-gradient( 2vmin 1.5vmin at 55% 72%, $w 5.5vmin, $t 6vmin ),
radial-gradient( 2vmin 1.5vmin at 35% 80%, $w 2.5vmin, $t 3vmin ),
radial-gradient( 2vmin 1.5vmin at 16% 70%, $w 4.5vmin, $t 5vmin ),
radial-gradient( 2vmin 0.9vmin at 50% 55%, $w 14.5vmin, $t 15vmin );
animation: moving-cloud 30s infinite linear;
}
&:nth-child( 2 ) {
@include w-h ( 50vmin, 30vmin );
top: 3%;
left: 72%;
opacity: 0.7;
background:
radial-gradient( 1vmin 1vmin at 21% 53%, $w 6.6vmin, $t 7vmin ),
radial-gradient( 1vmin 1vmin at 38% 42%, $w 8vmin, $t 8.4vmin ),
radial-gradient( 1vmin 1vmin at 59% 40%, $w 8.5vmin, $t 8.9vmin ),
radial-gradient( 1vmin 1vmin at 76% 34%, $w 3vmin, $t 3.4vmin ),
radial-gradient( 1vmin 1vmin at 82% 55%, $w 6vmin, $t 6.5vmin ),
radial-gradient( 2vmin 1.5vmin at 88% 66%, $w 5.5vmin, $t 6vmin ),
radial-gradient( 2vmin 1.5vmin at 74% 76%, $w 4vmin, $t 4.5vmin ),
radial-gradient( 2vmin 1.5vmin at 59% 80%,$w 5.5vmin, $t 6vmin ),
radial-gradient( 2vmin 1.1vmin at 39% 80%, $w 7.5vmin, $t 8vmin ),
radial-gradient( 2vmin 1.5vmin at 15.8% 68%,$w 7.5vmin, $t 7.9vmin ),
radial-gradient( 2vmin 1vmin at 42% 56%, $w 17vmin, $t 17.4vmin );
animation: moving-cloud 20s infinite linear;
}
&:nth-child( 3 ) {
@include w-h ( 25vmin, 15vmin );
top: 65%;
left: 63%;
opacity: 0.5;
background:
radial-gradient( 0.8vmin 1vmin at 33% 50%, $w 4vmin, $t 4.4vmin ),
radial-gradient( 1.5vmin 1vmin at 57% 35%, $w 6vmin, $t 6.5vmin ),
radial-gradient( 1.2vmin 1vmin at 79% 41%, $w 3vmin, $t 3.4vmin ),
radial-gradient( 2vmin 1.5vmin at 78% 65%, $w 4vmin, $t 4.5vmin ),
radial-gradient( 2vmin 1.5vmin at 55% 66%, $w 5.5vmin, $t 6vmin ),
radial-gradient( 2vmin 1.5vmin at 30% 80%, $w 2.5vmin, $t 3vmin ),
radial-gradient( 2vmin 1.5vmin at 17% 72%, $w 1.6vmin, $t 2vmin ),
radial-gradient( 2vmin 0.9vmin at 50% 55%, $w 10vmin, $t 10.5vmin );
animation: moving-cloud 40s infinite linear;
}
&:nth-child( 4 ) {
@include w-h ( 12vmin, 8vmin );
top: 90%;
left: 25%;
opacity: 0.4;
background:
radial-gradient( 1.2vmin 1vmin at 44% 35%, $w 2vmin, $t 2.4vmin ),
radial-gradient( 1.5vmin 1vmin at 66% 30%, $w 1vmin, $t 1.4vmin ),
radial-gradient( 2vmin 1.5vmin at 78% 75%, $w 1vmin, $t 1.5vmin ),
radial-gradient( 2vmin 1.5vmin at 55% 66%, $w 2.5vmin, $t 3vmin ),
radial-gradient( 2vmin 1.5vmin at 35% 80%, $w 1vmin, $t 1.4vmin ),
radial-gradient( 2vmin 1.5vmin at 17% 72%, $w 1.6vmin, $t 2vmin ),
radial-gradient( 2vmin 0.8vmin at 50% 55%, $w 5vmin, $t 5.5vmin );
animation: moving-cloud 50s infinite linear;
}
}
}
.madeline-container {
@include w-h( 40.5vmin, 91.8vmin );
animation: body-move 1.3s infinite alternate ease-in-out;
}
.balloon {
@include w-h( 20vmin, 24vmin );
position: absolute;
background: $r;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate3d( -114%, -200%, 0 );
animation: balloon-move 1.3s infinite alternate ease-in-out;
&::after {
@include pseduo-div( 2.2vmin, 1.6vmin, $r );
position: absolute;
top: 99.2%;
left: 44%;
transform: rotate( 5deg ) skewX( -5deg );
border-radius: 60% 60% 20% 20%;
}
&::before {
@include pseduo-div( 0.2vmin, 26vmin, darken( $pr, 40 ));
top: 100%;
left: 50.2%;
}
}
.head {
@include w-h( 79%, 26% );
position: relative;
top: 40%;
left: 11.5%;
// top bow ribbons
&::before,
&::after {
@include pseduo-div( 0, 0, $t );
z-index: -10;
border-bottom: 7vmin solid $b;
}
&::before {
border-right: 6vmin solid $t;
top: 5%;
left: 31.5%;
transform: rotateZ( -8deg );
}
&::after {
border-left: 6vmin solid $t;
top: 2%;
left: 42.5%;
transform: rotateZ( -3.5deg );
}
// hair
&__hair,
&__hair--fringe {
@include w-h( 80%, 47% );
position: absolute;
top: 52.5%;
left: 12%;
border-radius: 50% 50% 60% 60% / 90% 90% 35% 35%;
transform: rotateZ( 2.5deg );
overflow: hidden;
}
&__hair {
background-color: $o;
// fringe
&--fringe {
z-index: 20;
&::before,
&::after {
@include pseduo-div( 38%, 30%, $o );
border-radius: 50%;
}
&::before {
top: -5%;
left: 22%;
transform: rotate( -14deg );
}
&::after {
top: -10%;
left: 50%;
transform: rotate( 14deg );
}
}
}
&__face {
@include w-h( 44%, 42% );
border-radius: 30% 30% 60% 70% / 80% 80% 70% 70%;
position: absolute;
top: 57%;
left: 33.5%;
z-index: 10;
background:
// nose
radial-gradient( 12% 8% at 58% 60%, $skin 0.5vmin, $t 0.7vmin ),
radial-gradient( 10% 8% at 59% 63%, rgba( $b, 0.8 ) 0.4vmin, $t 0.5vmin ),
//mouth
linear-gradient( -50deg, $t 46%, $skin 46.5% ),
linear-gradient( 50deg, $t 51%, $skin 51.5% ),
radial-gradient( 2.4% 1.2% at 54% 74%, $skin 1.9vmin, $t 2.1vmin ),
radial-gradient( 2.2% 1.2% at 54% 76%, rgba( $b, 0.8 ) 2vmin, $t 2.2vmin ),
$skin;
// eyes
&::before,
&::after {
@include pseduo-div( 5%, 11%, rgba( $b, 0.8 ));
border-radius: 50%;
animation: eyes-blink 7s infinite;
will-change: transform;
}
&::before {
top: 32%;
left: 33%;
}
&::after {
top: 34%;
left: 70%;
}
}
&__hat {
@include w-h( 84%, 36% );
background-color: $y;
border-radius: 70% 70% 50% 50% / 70% 70% 80% 80%;
position: absolute;
top: 28%;
left: 13%;
transform: rotateZ( 4deg );
// ribbons
&::after,
&::before {
@include pseduo-div( 24%, 30%, rgba( $b, 0.8 ));
background:
radial-gradient( 1% 1.5% at 20% 120%, $t 3vmin, $b 3.1vmin, $b 5vmin, $t 5.1vmin),
radial-gradient( 2.2% 1.5% at 22% 107%, $t 3vmin, $b 3.2vmin, $b 6vmin, $t 6vmin);
}
&::before {
top: 80%;
left: -17%;
transform: rotate( -45deg );
}
&::after {
top: 103%;
left: -13%;
transform: rotate( -62deg );
}
}
}
.body {
@include w-h( 66%, 34.4% );
position: absolute;
top: 65.6%;
left: 23.5%;
transform-origin: 50% 0%;
animation: dress-sway 1.2s infinite alternate ease-in-out;
// dress
&::before {
@include pseduo-div( 84%, 66%, $n );
background-color: $n;
background-color: rgba( $n, 0.5 );
border-radius: 0 0 45% 55% / 0 0 18% 18%;
border-radius: 50% / 100% 100% 0% 0%;
transform: rotate( -3deg );
top: 0;
left: 3%;
background:
linear-gradient( -72.8deg, $t 35%, $n 35.5%,$n 77.3%, $t 77.7% ),
linear-gradient( 74deg, $t 42%, $n 42.5%, $n 78%, $t 78.5% );
}
&::after {
@include pseduo-div( 82.6%, 18%, $n );
border-radius: 50%;
top: 56.7%;
left: 5.5%;
transform: rotate( -3deg );
}
// legs
&__leg {
&-l,
&-r {
// Leg
&::after {
@include pseduo-div( 13%, 28%, null );
position: absolute;
background: radial-gradient( circle at 50% -50%, $skin 72%, $w 72.5% );
}
// Shoe
&::before {
@include pseduo-div( 20%, 7%, $b );
}
}
&-l {
&::after {
top: 69%;
left: 12.8%;
border-radius: 0 0 50% 50% / 0 0 5% 8%;
transform: rotate( 18deg );
}
&::before {
top: 93%;
left: 0.5%;
border-radius: 60% 50% 40% 30% / 80% 60% 70% 30%;
}
}
&-r {
&::after {
top: 68.2%;
left: 72%;
border-radius: 0 0 50% 50% / 0 0 10% 8%;
transform: rotate( -33deg );
}
&::before {
top: 89.5%;
right: -1.5%;
border-radius: 40% 60% 30% 40% / 60% 80% 30% 40%;
transform: rotate( -10deg );
}
}
}
}
.arm {
&__l,
&__r {
position: absolute;
@include w-h( 50%, 15% );
&::before {
@include pseduo-div( 75%, 25%, null );
}
}
&__l {
top: 66%;
left: 4%;
transform: rotate( 46deg );
transform-origin: 100% 0;
&::before {
top: 0%;
left: -18%;
transform: perspective( 20vmin ) rotateY( 135deg );
transform-origin: 50% 0%;
background:
radial-gradient( 2% 3% at 84% 10%, $w 1vmin, $t 1.1vmin ),
radial-gradient( 2% 3% at 83% 30%, $w 1vmin, $t 1.1vmin ),
radial-gradient( 2% 3% at 82% 50%, $w 1vmin, $t 1.1vmin ),
radial-gradient( 2% 3% at 81% 70%, $w 1vmin, $t 1.1vmin ),
radial-gradient( 2% 3% at 80% 90%, $w 1vmin, $t 1.1vmin ),
radial-gradient( circle at 0% 0%, $t 2vmin, $skin 2vmin, $skin 7.7vmin, $t 7.8vmin ),
radial-gradient( circle at 0% 0%, $t 2vmin, $w 2vmin, $w 12.5vmin, $t 12.6vmin );
}
&::after {
@include pseduo-div( 100%, 100%, yellow );
background:
radial-gradient( 1% 2% at 87% 6%, $w 2.6vmin, $t 2.7vmin ),
radial-gradient( 1% 2% at 90% 5%, $w 2.2vmin, $t 2.3vmin ),
radial-gradient( circle at 89% 16%, $w 2.2vmin, $t 2.3vmin ),
radial-gradient( 5% 8% at 108% -50%, $n 15.5vmin, $t 15.6vmin );
}
}
&__r {
transform: rotate( 2deg );
top: 65%;
left: 53%;
transform-origin: 0 0;
animation: arm-move-right 1.3s infinite alternate ease-in-out;
&::before {
top: 14%;
right: -14%;
transform: perspective( 20vmin ) rotateY( 35deg );
background:
radial-gradient( 2% 3% at 86% 10%, $w 1vmin, $t 1.1vmin ),
radial-gradient( 2% 3% at 85% 30%, $w 1vmin, $t 1.1vmin ),
radial-gradient( 2% 3% at 84% 50%, $w 1vmin, $t 1.1vmin ),
radial-gradient( 2% 3% at 83% 70%, $w 1vmin, $t 1.1vmin ),
radial-gradient( 2% 3% at 82% 90%, $w 1vmin, $t 1.1vmin ),
radial-gradient( circle at 0% 0%, $skin 8.2vmin, $t 8.3vmin ),
radial-gradient( circle at 0% 0%, $w 12.5vmin, $t 12.6vmin );
}
&::after {
@include pseduo-div( 75%, 100%, null );
clip-path: polygon( 0 0, 10% 100%, 100% 15% );
background:
radial-gradient( 2.5% 3% at 15% 5%, $w 2.2vmin, $t 2.3vmin ),
radial-gradient( 2.5% 3% at 17% 12%, $w 2.2vmin, $t 2.3vmin ),
radial-gradient( 2.5% 3% at 18% 12%, $w 2.2vmin, $t 2.3vmin ),
radial-gradient( 6% 5% at 0% 0%, $n 12.5vmin, $t 12.6vmin );
}
}
}
/* --- Animation --- */
@keyframes balloon-move {
0% {
margin-top: 0.5% ;
}
100% {
margin-top: 0% ;
}
}
@keyframes body-move {
0%, 6% {
transform: rotate( -1deg );
}
94%, 100% {
transform: rotate( 1deg );
}
}
@keyframes eyes-blink {
0% {
transform: scaleY( 1 );
}
2% {
transform: scaleY( 0.1 );
}
4% {
transform: scaleY( 1 );
}
6% {
transform: scaleY( 0.1 );
}
8% {
transform: scaleY( 1 );
}
66% {
transform: scaleY( 1 );
}
68% {
transform: scaleY( 0.1 );
}
70% {
transform: scaleY( 1 );
}
100% {
transform: scaleY( 1 );
}
}
@keyframes dress-sway {
0%, 5% {
transform: rotate( -1.2deg );
}
95%, 100% {
transform: rotate( 8deg );
}
}
@keyframes arm-move-right {
0%, 5% {
transform: rotate( -10deg );
}
95%, 100% {
transform: rotate( -4deg );
}
}
@keyframes moving-cloud {
0% {
margin-top: 100vh;
}
100% {
margin-top: -100vh;
}
}
// Twitter @anniebombanie_
Also see: Tab Triggers