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="character">
<div id="legs">
<div class="leg leg-1 hab"></div>
<div class="leg leg-2 ha"></div>
<div class="foot foot-1 hab"></div>
<div class="shoe-lace shoe-lace-1 hab"></div>
<div class="ankle ankle-1 hab"></div>
<div class="foot foot-2 hab"></div>
<div class="shoe-lace shoe-lace-2 r hb"></div>
</div>
<div id="body">
<div class="arm arm-1 ha"></div>
<div class="hand hand-1 r ha"></div>
<div class="skirts">
<div class="skirt skirt-1"></div>
<div class="skirt skirt-2"></div>
<div class="skirt skirt-3"></div>
<div class="skirt skirt-4"></div>
<div class="skirt skirt-5"></div>
<div class="skirt skirt-6"></div>
<div class="skirt skirt-7"></div>
</div>
<div class="chest ha"></div>
<div class="body hba"></div>
<div class="back r"></div>
<div class="elbow r ha"></div>
<div class="arm arm-2 ha"></div>
<div class="hand hand-2 b r hab"></div>
<div class="forearm"></div>
</div>
<div id="head">
<div class="hair hair-1"></div>
<div class="hair hair-2"></div>
<div class="hair hair-3"></div>
<div class="hair hair-4"></div>
<div class="hair hair-5"></div>
<div class="hair hair-6"></div>
<div class="hair hair-7"></div>
<div class="hair hair-8"></div>
<div class="lower-lip r ha"></div>
<div class="neck r"></div>
<div class="smile r ha"></div>
<div class="lip r ha"></div>
<div id="eyelids">
<div class="eyelid eyelid-1 r"></div>
<div class="eyelid eyelid-2 r"></div>
<div class="eyelid eyelid-3 r"></div>
<div class="eyelid eyelid-4 r"></div>
<div class="eyelid eyelid-5 r"></div>
<div class="eyelid eyelid-6 r"></div>
<div class="eyelid eyelid-7 r"></div>
<div class="eyelid eyelid-8 r"></div>
</div>
<div class="eye eye-1 r b ha"></div>
<div class="nose hab r b"></div>
<div class="eye eye-2 r b"></div>
<div class="ear hab r b"></div>
<div class="pearls">
<div class="pearl pearl-1 r b"></div>
<div class="pearl pearl-2 r b"></div>
<div class="pearl pearl-3 r b"></div>
<div class="pearl pearl-4 r b"></div>
<div class="pearl pearl-5 r b"></div>
</div>
</div>
</div>
<div id="links">
<a target="_blank" href="https://github.com/alvaromontoro/CSS-Simpsons">More on GitHub</a>
<a target="_blank" href="https://codepen.io/collection/DrwLdN/">More on CodePen</a>
</div>
html {
--yellow: #FDD835;
--blue: #70D1FE;
--red: #F44336;
overflow-x: hidden;
}
.character {
position: relative;
margin: auto auto;
/* these values change from character to character */
width: 432px;
height: 720px;
}
.character::after {
content: "";
position: absolute;
top: 0;
left: 0;
z-index:-1;
background-size: cover;
width: 100%;
height: 100%;
opacity: 0;
/* this value changes from character to character */
background-image: url(https://upload.wikimedia.org/wikipedia/en/e/ec/Lisa_Simpson.png);
}
.character::before {
content: "";
display: block;
position: absolute;
border-radius: 100%;
background: #ccc;
filter: blur(5px);
z-index: -1;
/* these values change from character to character */
left: 100px;
top: 635px;
width: 320px;
height: 45px;
}
/* while drawing */
.character > div {
opacity: 1;
}
.character > div > div,
.character > div > div > div {
position: absolute;
box-sizing: border-box;
transform-origin: top left;
}
/* set common values to all the ::before and ::after (revmoes repetition, DRY!) */
.hb::before, .ha::after,
.hba::before, .hba::after,
.hab::before, .hab::after {
content: "";
display: block;
position: absolute;
transform-origin: top left;
}
.r {
border-radius: 100%;
}
.b {
border: 3px solid #000;
}
/***********/
.eye {
background: #000;
}
.eye-1 {
width: 77px;
height: 77px;
top: 145px;
left: 106px;
box-shadow: inset -10px 1px 0 30px #fff;
}
.eye-1::after {
width: 40px;
height: 40px;
bottom: 3px;
right: 0px;
background: #fff;
}
.eye-2 {
width: 86px;
height: 86px;
top: 140px;
left: 174px;
box-shadow: inset 5px 6px 0 34px #fff;
}
.nose {
width: 34px;
height:34px;
border-bottom: 3px solid transparent;
border-right: 3px solid transparent;
top: 222px;
left: 127px;
transform: rotate(-45deg);
background: var(--yellow);
}
.nose::before {
top: -2px;
left: 25px;
width: 60px;
height: 8px;
border-radius: 100%;
box-shadow: inset 0px -4px 0 -1px #000, 0 6px 0 5px var(--yellow);
transform: rotate(36deg);
}
.nose::after {
top: 16px;
left: 0px;
width: 35px;
height: 6px;
border-radius: 100%;
box-shadow: inset 0px -4px 0 -1px #000;
transform: rotate(45deg);
}
.pearl {
width: 30px;
height: 30px;
background: #fff;
}
.pearl-1 {
width: 28px;
height: 28px;
top: 311px;
left: 153px;
}
.pearl-2 {
width: 29px;
height: 29px;
top: 307px;
left: 247px;
}
.pearl-3 {
top: 316px;
left: 224px;
}
.pearl-4 {
top: 314px;
left: 168px;
}
.pearl-5 {
top: 317px;
left: 195px;
}
.ear {
height: 43px;
width: 39px;
top: 221px;
left: 265px;
border-left: 3px solid transparent;
background: var(--yellow);
transform: rotate(10deg);
}
.ear::before {
top: 6px;
left: 20px;
height: 22px;
width: 14px;
border-radius: 100%;
box-shadow: inset 4px 0 0 -1px black;
transform: rotate(38deg);
}
.ear::after {
top: 17px;
left: 10px;
height: 14px;
width: 9px;
border-radius: 100%;
box-shadow: inset -4px 0 0 -1px black;
transform: rotate(-38deg);
}
.smile {
top: 234px;
left: 100px;
width: 150px;
height: 38px;
box-shadow: inset 0 -4px 0 -1px #000;
transform: rotate(3deg);
background: var(--yellow);
}
.smile::after {
top: 13px;
right: 1px;
height: 20px;
width: 9px;
border-radius: 100%;
box-shadow: inset -4px 0 0 -1px black;
transform: rotate(-20deg);
}
.lip {
width: 30px;
height: 27px;
top: 235px;
left: 97px;
border: 3px solid transparent;
border-left: 3px solid #000;
box-shadow: inset 60px 0 var(--yellow);
}
.lip::after {
top: -30px;
left: 20px;
height: 40px;
width: 7px;
border-radius: 100%;
transform: rotate(40deg);
box-shadow: 3px 0 #000, 20px -20px 0 20px var(--yellow);
}
.lower-lip {
top: 256px;
left: 175px;
height: 30px;
width: 34px;
border: 3px solid transparent;
border-left: 3px solid #000;
border-bottom: 3px solid;
transform: rotate(50deg);
background: var(--yellow);
}
.lower-lip::after {
top: 23px;
left: 22px;
width: 92px;
height: 35px;
background: var(--yellow);
transform: rotate(-50deg);
box-shadow: inset 4px 0 0 -1px #000, inset -4px 0 0 -1px #000, 0 -35px var(--yellow), 13px -129px 0 60px var(--yellow), -10px -200px 0 45px var(--yellow);
}
.neck {
top: 255px;
left: 273px;
width: 7px;
height: 40px;
box-shadow: -3px 0 black, -10px -1px 0 2px var(--yellow);
transform: rotate(18deg);
}
.hair {
width: 70px;
height: 70px;
border-radius: 10px 0 0 0;
border: 3px solid transparent;
border-left: 3px solid #000;
border-top: 3px solid #000;
background: var(--yellow);
}
.hair-1 {
top: 128px;
left: 58px;
transform: rotate(-45deg) skewY(200deg);
}
.hair-2 {
top: 3px;
left: 202px;
transform: rotate(40deg) skewY(5deg);
}
.hair-3 {
top: 38px;
left: 99px;
transform: rotate(-10deg) skewY(14deg);
}
.hair-4 {
top: 30px;
left: 302px;
transform: rotate(75deg) skewY(5deg);
}
.hair-5 {
width: 59px;
height: 55px;
top: 102px;
left: 362px;
transform: rotate(105deg) skewY(6deg);
}
.hair-6 {
width: 59px;
height: 55px;
top: 192px;
left: 378px;
transform: rotate(135deg) skewY(5deg);
}
.hair-7 {
width: 45px;
height: 45px;
top: 265px;
left: 350px;
transform: rotate(165deg) skewY(5deg);
}
.hair-8 {
width: 45px;
height: 30px;
top: 299px;
left: 305px;
transform: rotate(185deg) skewY(5deg);
box-shadow: 3px 10px 0 var(--yellow);
}
.arm-1 {
top: 400px;
left: 63px;
width: 130px;
height: 60px;
border: 3px solid transparent;
border-top: 3px solid #000;
border-left: 3px solid #000;
border-radius: 50px 0 0;
background: var(--yellow);
transform: rotate(-35deg);
}
.arm-1::after {
top: -1px;
left: 40px;
width: 60px;
height: 50px;
border: 3px solid transparent;
border-top: 3px solid #000;
border-radius: 100%;
transform: rotate(65deg);
}
.hand-1 {
width: 40px;
height: 30px;
border: 3px solid black;
top: 443px;
left: 95px;
transform: rotate(30deg);
background: var(--yellow);
}
.hand-1::after {
width: 8px;
height: 20px;
top: -4px;
left: -4px;
border-radius: 100%;
border: 3px solid transparent;
border-left: 3px solid black;
transform: rotate(-30deg);
background: var(--yellow);
box-shadow: 14px -6px 0 10px var(--yellow);
}
.arm-2 {
top: 322px;
left: 272px;
width: 60px;
height: 55px;
border-bottom: 3px solid #000;
transform: rotate(43deg) skewX(10deg);
background: var(--yellow);
box-shadow: 30px 0px 0 -1px var(--yellow);
}
.arm-2::after {
top: -4px;
left: -2px;
width: 100px;
height: 20px;
border-radius: 100%;
box-shadow: inset 0 4px 0 -1px #000;
background: var(--yellow);
}
.elbow {
top: 371px;
left: 301px;
width: 42px;
height: 74px;
box-shadow: inset -4px 0 0 -1px #000;
background: var(--yellow);
}
.elbow::after {
top: 35px;
right: -5px;
height: 40px;
width: 43px;
background: var(--yellow);
border-right: 3px solid #000;
transform: rotate(48deg)
}
.chest {
top: 330px;
left: 166px;
height: 50px;
width: 110px;
border-left: 3px solid #000;
transform: skewX(-22deg);
background: var(--yellow);
}
.chest::after {
bottom: 0;
left: -10px;
border-radius: 100%;
box-shadow: inset 0 4px 0 -1px #000, 0 8px 0 3px var(--red);
width: 110px;
height: 20px;
transform: skewX(22deg) rotate(4deg);
background: var(--red);
}
.body {
top: 350px;
left: 115px;
height: 155px;
width: 110px;
background: var(--red);
margin: 30px;
}
.body::before {
height: 164px;
width: 70px;
top: -12px;
left: 1px;
border-left: 3px solid #000;
transform: rotate(20deg);
background: var(--red);
}
.body::after {
top: 103px;
left: -47px;
width: 8px;
height: 50px;
box-shadow: 4px 0 0 -1px #000, 10px 5px 0 4px var(--red), 30px 5px 0 8px var(--red), 55px -3px 0 8px var(--red), 85px -23px 0 11px var(--red);
border-radius: 100%;
transform: rotate(28deg);
}
.back {
top: 370px;
left: 251px;
height: 170px;
width: 20px;
box-shadow: -4px 0 0 -1px, -102px 0 0 10px var(--red), -52px 0 0 15px var(--red), -20px 0 0 -1px var(--red), -10px 0 0 -1px var(--red), -30px -4px 0 0px var(--red);
transform: rotate(-17deg);
}
.skirt {
width: 30px;
height: 50px;
border-radius: 0 0 0 10px;
border: 3px solid transparent;
border-left: 3px solid #000;
border-bottom: 3px solid #000;
background: var(--red);
}
.skirt-1 {
top: 526px;
left: 82px;
width: 25px;
height: 30px;
transform: rotate(45deg) skewY(-55deg);
}
.skirt-2 {
top: 541px;
left: 93px;
width: 25px;
height: 30px;
transform: rotate(5deg) skewY(-45deg);
}
.skirt-3 {
top: 547px;
left: 116px;
width: 35px;
height: 35px;
transform: rotate(-10deg) skewY(-40deg);
box-shadow: 0 -10px 0 var(--red);
}
.skirt-4 {
top: 546px;
left: 149px;
width: 36px;
height: 39px;
transform: rotate(-24deg) skewY(-38deg);
}
.skirt-5 {
top: 541px;
left: 182px;
width: 46px;
height: 53px;
transform: rotate(-40deg) skewY(-30deg);
}
.skirt-6 {
top: 538px;
left: 229px;
width: 46px;
height: 53px;
transform: rotate(-50deg) skewY(-29deg);
}
.skirt-7 {
top: 537px;
left: 276px;
width:31px;
height: 48px;
transform: rotate(-80deg) skewY(-54deg);
box-shadow: inset -3px -2px 0 0 #000;
}
.hand-2 {
top: 433px;
left: 270px;
width: 61px;
height: 50px;
transform: rotate(38deg);
background: var(--yellow);
}
.hand-2::after {
top: 1px;
right: 6px;
border-radius: 100%;
width: 17px;
height: 26px;
background: var(--yellow);
box-shadow: inset -4px 0 0 -1px #000, -22px 4px 0 11px var(--yellow), -24px 0px 0 11px var(--yellow), -25px -4px 0 11px var(--yellow), -10px -4px 0 4px var(--yellow), -26px 2px 0 11px #000;
}
.hand-2::before {
right: 5px;
top: 28px;
width: 16px;
height: 15px;
border-radius: 100%;
border: 1px solid transparent;
border-right: 3px solid #000;
transform: rotate(-60deg)
}
.forearm {
top: 400px;
left: 288px;
width: 6px;
border-radius: 100%;
height: 60px;
border-right: 3px solid #000;
transform: rotate(36deg);
box-shadow: 12px 0 0 10px var(--yellow);
}
.leg {
background: var(--yellow);
}
.leg-1 {
top: 518px;
left: 104px;
width: 48px;
height: 104px;
transform: skewY(30deg) rotate(4deg);
}
.leg-1::after {
left: 0px;
top: 6px;
height: 100px;
width: 14px;
box-shadow: inset 4px 0 0 -1px #000, inset 0 0 0 10px var(--yellow);
border-radius: 100%;
transform: rotate(3deg)
}
.leg-1::before {
right: -14px;
top: -10px;
height: 110px;
width: 14px;
box-shadow: inset 4px 0 0 -1px #000, -10px 0 0 10px var(--yellow);
border-radius: 100%;
transform: rotate(1deg)
}
.leg-2 {
top: 530px;
left: 208px;
height: 120px;
width: 67px;
transform: skewY(25deg) rotate(-34deg);
border-right: 4px solid black;
}
.leg-2::after {
left: -6px;
top: 6px;
height: 80px;
width: 14px;
box-shadow: inset 5px 0 0 -1px #000, inset 0 0 0 10px var(--yellow);
border-radius: 100%;
}
.eyelid {
width: 30px;
height: 10px;
border: 3px solid transparent;
border-bottom: 3px solid #000;
}
.eyelid-1 {
top: 172px;
left: 88px;
transform: rotate(9deg);
}
.eyelid-2 {
top: 142px;
left: 104px;
transform: rotate(36deg);
}
.eyelid-3 {
top: 126px;
left: 137px;
transform: rotate(74deg);
}
.eyelid-4 {
top: 135px;
left: 178px;
transform: rotate(110deg);
}
.eyelid-5 {
top: 127px;
left: 197px;
transform: rotate(72deg);
}
.eyelid-6 {
top: 125px;
left: 238px;
transform: rotate(100deg);
}
.eyelid-7 {
top: 149px;
left: 272px;
transform: rotate(130deg);
}
.eyelid-8 {
top: 190px;
left: 280px;
transform: rotate(170deg);
}
.foot-1 {
width: 98px;
height: 55px;
top: 615px;
left: 55px;
transform-origin: center;
}
.foot-1::after {
bottom: -5px;
left: 0;
width: 100px;
height: 30px;
box-shadow: inset 0 -4px 0 -1px #000, inset -4px -2px 0 -1px #000, inset -40px -14px 0 0 var(--red);
border-radius: 100%;
transform-origin: bottom left;
transform: rotate(-6deg);
}
.foot-1::before {
bottom: -0px;
left: 6px;
width: 62px;
height: 20px;
border-radius: 100%;
transform-origin: bottom left;
transform: rotate(-44deg);
box-shadow: inset 0px 4px 0 -1px #000, 20px 20px 0 7px var(--red), 10px 10px var(--red);
background: var(--red);
}
.shoe-lace-1 {
top:635px;
left: 70px;
width: 19px;
height: 20px;
border-bottom: 3px solid black;
transform: skewX(32deg) rotate(-3deg);
background: var(--yellow);
box-shadow:inset 4px 1px 0 -1px #000, 1px 0px var(--yellow);
}
.shoe-lace-1::after {
bottom:-5px;
right: -5px;
width: 4px;
height: 28px;
border-radius: 100%;
border: 4px solid transparent;
border-right: 3px solid black;
transform: rotate(3deg);
}
.shoe-lace-1::before {
border:10px solid transparent;
border-bottom: 10px solid var(--yellow);
top: -20px;
left: 19px;
transform: skewX(-32deg) rotate(9deg);
}
.ankle-1 {
top: 620px;
left: 97px;
width: 34px;
height: 29px;
background: var(--yellow);
transform: skewX(30deg) rotate(-5deg);
box-shadow: 7px -10px 0 -1px var(--yellow);
}
.ankle-1::before {
top: -3px;
left: -9px;
width: 6px;
height: 30px;
border-radius: 100%;
border: 3px solid transparent;
border-right: 4px solid #000;
}
.ankle-1::after {
bottom: -4px;
left: -4px;
width: 38px;
height: 8px;
border-radius: 100%;
border: 3px solid transparent;
border-bottom: 3px solid #000;
transform: rotate(-3deg);
}
.foot-2 {
top: 615px;
left: 272px;
width: 65px;
height: 60px;
transform-origin: bottom right;
transform: rotate(30deg);
border-radius: 100px 10px 250px 10px;
background: var(--red);
box-shadow: 3px 0 0 #000, 0px 3px 0 #000;
}
.foot-2::before {
left: -15px;
top: 15px;
width: 20px;
height: 50px;
border-radius: 100%;
box-shadow: inset 4px 0 0 -1px black;
transform: rotate(-10deg);
background: var(--red);
}
.foot-2::after {
top: 0;
left: -10px;
width: 75px;
height: 40px;
border-radius: 100%;
box-shadow: inset 0 5px 0 -1px #000, inset 8px 9px 0 2px var(--red);
transform: rotate(-10deg);
}
.shoe-lace-2 {
left: 240px;
top: 620px;
height: 80px;
width: 91px;
border:14px solid transparent;
border-top: 15px solid black;
transform: rotate(10deg);
}
.shoe-lace-2::before {
left: -4px;
top: -13px;
height: 45px;
width: 60px;
border-radius: 100%;
border:6px solid transparent;
border-top: 9px solid var(--yellow);
transform: rotate(1deg);
}
#links {
width: 200px;
height: 200px;
position: fixed;
top: 0;
right: 0;
transform: rotate(45deg);
}
#links a {
display: block;
background: black;
color: white;
text-align: center;
line-height: 20px;
height: 20px;
font-size: 14px;
text-decoration: none;
margin: 3px;
font-family: Arial, Verdana, sans-serif;
}
#links a:nth-child(2) {
background: green;
}
@media all and (max-width: 1000px) {
html, body { overflow-x: auto; }
#links {
display: none;
}
}
Also see: Tab Triggers