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 version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 800 600" xml:space="preserve">
<defs>
<clipPath id="eyeClipL">
<circle cx="327.772" cy="236.345" r="51.858" />
</clipPath>
<clipPath id="eyeClipR">
<circle cx="465.639" cy="236.372" r="51.858"/>
<!-- <circle cx="465.639" cy="235.08" r="51.858" /> -->
</clipPath>
</defs>
<g id="hair">
<polyline fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke-miterlimit="10" points="
497.87,290 524.348,245 537.13,287.261 " />
<polyline fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke-miterlimit="10" points="
296.13,290 269.652,245 256.87,287.261 " />
</g>
<g id="hairTop">
<path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10"
d="M312,88l0.229-2.432
c1.354-14.361,6.516-28.181,15.356-39.58C339.601,30.494,361.103,15,399.048,15c63.381,0,79.121,45.877,82.588,61L484,92" />
<path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="M333,75
c0-8,2.338-17.68,2.338-17.68S342.741,24,398.263,24s61.075,35.36,61.075,35.36L461,73" />
</g>
<g>
<polygon id="neck" fill="#FED90F" stroke="#000000" stroke-width="2" stroke-miterlimit="10" points="497.168,518.401
298.773,518.401 328.698,410.891 470.568,410.891 " />
<path fill="#FED90F" stroke="#000000" stroke-width="2" stroke-miterlimit="10" d="M491,494c4.237,6.223,4.994,13.536,4.994,20.607
c0,30.735-43.89,55.652-98.024,55.652s-98.024-24.917-98.024-55.652c0-6.577,1.361-12.751,5.054-18.607" />
</g>
<g id="bodyGroup">
<path id="body" fill="#FFF" stroke="#000000" stroke-width="2" stroke-miterlimit="10" d="M626.879,600.472
C602.774,547.072,552.239,500.912,492,496c4.237,6.223,3.994,11.536,3.994,18.607c0,30.735-43.89,55.652-98.024,55.652
s-98.024-24.917-98.024-55.652c0-6.577,0.581-12.751,4.275-18.607c-70.8,11.929-103.914,52.282-129.203,103.025l-0.831,1.705"/>
<!-- <line fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" x1="284.365" y1="499.983" x2="258.69" y2="601.73"/>
<line fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" x1="516.69" y1="499.983" x2="542.365" y2="601.73"/> -->
</g>
<g id="ears">
<g id="earR">
<ellipse fill="#FED90F" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="511.172" cy="296.424"
rx="21.502" ry="27.194" />
<g id="earDetail">
<path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="M512.006,300.997
c0,0-0.617-6.168,3.41-10.177c1.64-1.632,4.049-2.907,7.584-3.26" />
<path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="M520.557,303.44
c0,0-0.094-12.594-4.98-12.594" />
</g>
</g>
<g id="earL">
<ellipse fill="#FED90F" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="284.768" cy="296.424"
rx="22.767" ry="27.194" />
<g id="earDetail">
<path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="M282.966,300.997
c0,0,0.617-6.168-3.41-10.177c-1.64-1.632-4.049-2.907-7.584-3.26" />
<path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="M274.415,303.44
c0,0,0.094-12.594,4.98-12.594" />
</g>
</g>
</g>
<path id="head" fill="#FED90F" stroke="#000000" stroke-width="2" stroke-miterlimit="10" d="M397.338,443.777h-35.47
c-46.772,0-78.159-37.916-78.159-84.689l-2.735-98.711v-45.534v0c-7.169-11.152-8.689-25.021-4.106-37.461l1.576-4.279
l-1.265-13.281c0-66.012,54.146-119.526,120.158-119.526h0c66.012,0,120.159,53.514,120.159,119.526l-1.265,13.281l1.576,4.279
c4.583,12.44,3.063,26.309-4.106,37.461v0v45.534l-2.735,98.711c0,46.772-31.387,84.689-78.159,84.689
C432.808,443.777,397.338,443.777,397.338,443.777z" />
<g id="mouthGroup">
<path id="beard" fill="#D1B271" stroke="#000000" stroke-width="2" stroke-miterlimit="10" d="M518.761,375.159
c0-11.954-6.206-23.142-17.004-32.729c-16.727-36.816-57.359-62.802-104.836-62.802c-47.199,0-87.632,25.683-104.539,62.156
c-11.251,9.728-17.733,21.153-17.733,33.375c0,10.136,4.464,19.722,12.402,28.249c11.921,44.04,56.584,76.771,109.869,76.771
c53.555,0,98.405-33.062,110.053-77.44C514.529,394.381,518.761,385.03,518.761,375.159z" />
<g id="mouth">
<path id="shape" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="M312.594,375.476
c12.884,16.674,47.114,41.977,88.538,42.436c27.706,0.307,58.63-10.5,88.538-42.436" />
<line id="line1" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10"
x1="307.535" y1="381.8" x2="318.919" y2="367.887" />
<line id="line2" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10"
x1="495.994" y1="381.8" x2="483.346" y2="367.887" />
</g>
<path display="none" id="shape2" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="
M312.505,376.293c0,0,42.337-23.951,85.392-23.951c51.027,0,90.599,23.951,90.598,23.951" />
<path id="mouthDetail" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="
M411,393c0,0-17,6-25,0"/>
</g>
<path id="nose" fill="#FED90F" stroke="#000000" stroke-width="2" stroke-miterlimit="10" d="M366,257c0,0,0,22,0,22.349
c0,16.765,14.103,30.356,31.5,30.356s31.5-13.591,31.5-30.356C429,279,429,257,429,257" />
<rect id="noseMask" x="324" y="222" fill="#FED90F" width="159" height="36" />
<g id="eyes">
<g id="eyeL">
<circle fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="327.772" cy="236.345"
r="51.858" />
<g>
<circle class="iris" cx="317.772" cy="236.345" r="11.174" />
</g>
<g clip-path="url(#eyeClipL)">
<path id="eyeLidL" fill="#FED90F" stroke="#000000" stroke-width="2" stroke-miterlimit="10" d="M275.914,236.345
c0-28.64,23.218-51.858,51.858-51.858c28.64,0,51.858,23.218,51.858,51.858l-7.174-1.571
C340.59,227.794,307.537,228.332,275.914,236.345L275.914,236.345z"/>
</g>
<circle fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="327.772" cy="236.345"
r="51.858" />
</g>
<g id="eyeR">
<circle fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="465.639" cy="236.372" r="51.858"/>
<g>
<circle class="iris" cx="455.639" cy="236.372" r="10.92"/>
</g>
<g clip-path="url(#eyeClipR)">
<path id="eyeLidR" fill="#FED90F" stroke="#000000" stroke-width="2" stroke-miterlimit="10" d="M413.781,235.08
c0-28.64,23.218-51.858,51.858-51.858c28.64,0,51.858,23.218,51.858,51.858l-7.174-1.571
C478.457,226.529,445.403,227.067,413.781,235.08L413.781,235.08z"/>
</g>
<circle fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="465.639" cy="236.372" r="51.858"/>
</g>
</g>
<g id="browGroup">
<g id="brows">
<polyline id="browL" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" points="
287.223,204.016 373,210 384,203 "/>
<polyline id="browR" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" points="
506,204 506,204 420,210 409,203 "/>
</g>
<path id="browTopR" fill="#FED90F" d="M507.013,202.901c-5.745-13.404-19.141-21.894-33.715-21.367l-34.382,1.244
c-13.731,0.497-23.189,6.168-29.886,18.165l-0.017-0.042l0,0l11.288,8.088L507.013,202.901z"/>
<path id="browTopL" fill="#FED90F" d="M286.888,202.912L372.855,209l11.191-8.088l0,0l0,0
c-6.64-11.997-16.034-17.626-29.646-18.123l-34.087-1.244C305.865,181.018,292.583,189.508,286.888,202.912L286.888,202.912z"/>
</g>
</svg>
<div class="controls-container" data-state="closed">
<button class="btn-toggle">Slider Controls</button>
<div class="controls">
<div class="flex-container">
<input type="checkbox" class="input-toggle" data-checked="false" id="toggle">
<label for="toggle" id="toggle-label">Enable controls</label>
</div>
<label for="x">X-Axis controls :</label>
<input type="range" min="0" max="100" value="0" class="x-axis" id="x">
<label for="y">Y-Axis controls :</label>
<input type="range" min="0" max="100" value="0" class="y-axis" id="y">
<p>X/Y-Axis :</p>
<div class="freeform-move-container">
<div class="freeform-move-controls"></div>
</div>
</div>
</div>
@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700");
:root {
--blue : #70d1fe;
--red : #EA5B38;
}
html,body {
height:100%;
}
body {
display:flex;
align-items:center;
justify-content:center;
background:var(--blue);
font-family:"Open Sans";
font-size:16px;
}
svg {
width:100%;
max-height:100vh;
visibility:hidden;
}
.controls-container {
position:absolute;
top:10px;
left:15px;
background:#fff;
border-radius:8px;
padding:15px;
margin:15px;
transition:0.2s ease height;
&[data-state="closed"] {
opacity:1;
height:24px;
& .controls {
visibility:hidden;
opacity:0;
}
}
&[data-state="open"] {
height:305px;
.controls {
visibility:visible;
opacity:1;
transition:opacity 0.16s ease 0.2s,visibility 0.01s ease;
}
}
& button {
margin:0 0 10px 0px;
background:none;
border:none;
font-weight:bold;
font-size:20px;
cursor:pointer;
padding:0;
}
& input[type="range"] {
display:block;
margin:15px 0px;
-webkit-appearance:none;
appearance:none;
background:var(--blue);
width:100%;
height:4px;
cursor:pointer;
}
& ::-webkit-slider-thumb {
-webkit-appearance:none;
appearance:none;
width:10px;
height:20px;
background:var(--red);
border-radius:4px;
}
& label {
margin:7.5px 0px;
display:block;
}
& #toggle-label {
display:inline-block;
margin-left:5px;
}
& input[type="checkbox"] {
-webkit-appearance:none;
appearance:none;
width:16px;
height:16px;
background:var(--red);
transition:0.16s ease all;
cursor:pointer;
&:checked {
background:green;
}
}
& .flex-container {
display:flex;
align-items:center;
}
& .freeform-move-container {
width: 100%;
height: 80px;
background: lightgrey;
border-radius: 4px;
& .freeform-move-controls {
width:12px;
height:12px;
background:var(--red);
}
}
}
gsap.set("svg", { visibility: "visible" });
gsap.set("#mouthDetail", { drawSVG: "50% 50%", opacity: 0 });
gsap.set("#eyeLidL", { y: -48 });
gsap.set("#eyeLidR", { y: -48 });
gsap.set("#browL", { drawSVG: "40% 40%", y: -24, opacity: 0 });
gsap.set("#browR", { drawSVG: "40% 40%", y: -24, opacity: 0 });
gsap.set("#browTopL", { y: -23, transformOrigin: "50% 50%" });
gsap.set("#browTopR", { y: -23, transformOrigin: "50% 50%" });
const leftRight = gsap.timeline({ paused: true, defaults: { ease: "linear" } });
leftRight
.fromTo("#ears", { x: 14 }, { x: 0 }, "one")
.fromTo("#eyes", { x: 2 }, { x: 0 }, "one")
.fromTo("#hair", { x: 12 }, { x: 0 }, "one")
.fromTo("#hairTop", { x: 26, y: 0 }, { x: 0 }, "one")
.fromTo(
"#head",
{ rotation: 4, transformOrigin: "50% 100%" },
{ rotation: 0 },
"one"
)
.fromTo(
"#nose",
{ rotation: 20, scaleY: 1.1, x: 6, transformOrigin: "50% 0%" },
{ x: 0, rotation: 0, scaleY: 1 },
"one"
)
.fromTo(
"#mouthGroup",
{ x: 0, rotation: 2, transformOrigin: "50% 50%" },
{ x: 0, rotation: 0 },
"one"
)
.fromTo("#browGroup", { x: 2 }, { x: 0 }, "one")
.to("#ears", { x: -14 }, "two")
.to("#eyes", { x: -2 }, "two")
.to("#hair", { x: -12 }, "two")
.to("#hairTop", { x: -26, y: 0 }, "two")
.to("#head", { rotation: -4, transformOrigin: "50% 100%" }, "two")
.to(
"#nose",
{ rotation: -20, scaleY: 1.1, x: -6, transformOrigin: "50% 0%" },
"two"
)
.to("#mouthGroup", { x: 3, rotation: -2, transformOrigin: "50% 50%" }, "two")
.to("#browGroup", { x: -2 }, "two");
const upDown = gsap.timeline({ paused: true, defaults: { ease: "linear" } });
upDown
.fromTo("#ears", { y: 6 }, { y: 0 }, "up")
.fromTo("#hair", { y: 6 }, { y: 0 }, "up")
.fromTo("#mouthGroup", { y: -6 }, { y: 0 }, "up")
.fromTo("#eyes", { y: -6 }, { y: 0 }, "up")
.fromTo("#nose", { y: -6 }, { y: 0 }, "up")
.fromTo("#noseMask", { y: -6 }, { y: 0 }, "up")
.fromTo("#noseMask", { y: -6 }, { y: 0 }, "up")
.fromTo("#browTopL", { y: -30, scale: 0.8 }, { y: -23, scale: 0.9 }, "up")
.fromTo("#browTopR", { y: -30, scale: 0.8 }, { y: -23, scale: 0.9 }, "up")
.to("#ears", { y: -6 }, "down")
.to("#hair", { y: -6 }, "down")
.to("#mouthGroup", { y: 6 }, "down")
.to("#eyes", { y: 6 }, "down")
.to("#nose", { y: 6 }, "down")
.to("#noseMask", { y: 6 }, "down")
.to("#shape", { morphSVG: "#shape2", duration: 0.24 }, "down+=0.2")
.to(
"#line1",
{ rotation: -55, x: -1, transformOrigin: "50% 50%", duration: 0.24 },
"down+=0.2"
)
.to(
"#line2",
{ rotation: 55, transformOrigin: "50% 50%", duration: 0.24 },
"down+=0.2"
)
.to("#mouthDetail", { opacity: 1, duration: 0.01 }, "down+=0.3")
.to("#mouthDetail", { drawSVG: "0% 100%", duration: 0.08 }, "down+=0.32")
.to("#browGroup", { y: 6 }, "down")
.to("#eyeLidL", { y: 0, duration: 0.3 }, "down+=0.24")
.to("#eyeLidR", { y: 0, duration: 0.3 }, "down+=0.24")
.to("#browL", { opacity: 1, duration: 0.01 }, "down+=0.025")
.to("#browR", { opacity: 1, duration: 0.01 }, "down+=0.025")
.to("#browL", { drawSVG: "12% 78%", duration: 0.2 }, "down+=0.025")
.to("#browR", { drawSVG: "12% 78%", duration: 0.2 }, "down+=0.025")
.to("#browL", { drawSVG: "0% 100%", duration: 0.2 }, "down+=0.225")
.to("#browR", { drawSVG: "0% 100%", duration: 0.2 }, "down+=0.225")
.to("#browL", { y: 0 }, "down")
.to("#browR", { y: 0 }, "down")
.to("#browTopL", { y: 0, scale: 0.99, transformOrigin: "50% 50%" }, "down")
.to("#browTopR", { y: 0, scale: 0.99, transformOrigin: "50% 50%" }, "down");
const xAxis = document.querySelector(".x-axis");
const yAxis = document.querySelector(".y-axis");
const toggle = document.querySelector(".input-toggle");
const btnToggle = document.querySelector(".btn-toggle");
const controls = document.querySelector(".controls-container");
toggle.addEventListener("click", () => {
toggle.dataset.checked === "false"
? (toggle.dataset.checked = "true")
: (toggle.dataset.checked = "false");
});
xAxis.addEventListener("input", e => {
if (toggle.dataset.checked === "true") {
x = xAxis.value / 100;
gsap.set(leftRight, { progress: x });
}
});
yAxis.addEventListener("input", e => {
if (toggle.dataset.checked === "true") {
y = yAxis.value / 100;
gsap.set(upDown, { progress: y });
}
});
btnToggle.addEventListener("click", () => {
controls.dataset.state === "closed"
? (controls.dataset.state = "open")
: (controls.dataset.state = "closed");
});
window.addEventListener("mousemove", e => {
x = e.clientX / window.innerWidth;
y = e.clientY / window.innerHeight;
if (toggle.dataset.checked === "false") {
gsap.set(".iris", { x: x * 20, y: y * 20 });
gsap.set(leftRight, { progress: x });
gsap.set(upDown, { progress: y });
}
});
const dragger = new Draggable(".freeform-move-controls", {
type: "x,y",
bounds: ".freeform-move-container",
onDrag: e => {
let x = gsap.getProperty(".freeform-move-controls", "x") / 118;
let y = gsap.getProperty(".freeform-move-controls", "y") / 68;
if (toggle.dataset.checked === "true") {
gsap.set(leftRight, { progress: x });
gsap.set(upDown, { progress: y });
}
}
});
Also see: Tab Triggers