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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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 width="100vw" height="100vh" viewBox="0 0 332 332" fill="none" xmlns="http://www.w3.org/2000/svg" onmousemove="moveFunc(event);" ontouchmove="moveFunc(event);">
<g id="Worm_Frame">
<rect id="Grass" y="215" width="332" height="117" fill="#24591C" />
<ellipse id="Hole" cx="165.5" cy="276.5" rx="75.5" ry="24.5" fill="#193E13" />
<path id="Worm\" fill-rule="evenodd" clip-rule="evenodd" d="M217 294.416C203.511 298.5 185.405 301 165.5 301C146.083 301 128.377 298.621 115 294.713L115 80C115 51.8335 137.833 29 166 29C194.167 29 217 51.8335 217 80V294.416Z" fill="#F4BCAB" />
<path id="Smile" d="M177 122.5C177 125.55 175.788 128.475 173.632 130.632C171.475 132.788 168.55 134 165.5 134C162.45 134 159.525 132.788 157.368 130.632C155.212 128.475 154 125.55 154 122.5" stroke="#424242" stroke-width="4" stroke-linecap="round" />
<g class="eye_group">
<g id="Eye_Group_L" class="innerGroup">
<rect id="Eye_L" x="126" y="80" width="36" height="36" rx="18" fill="white" />
<rect id="pupil_L" x="128" y="86" width="14" height="14" rx="7" fill="#424242" />
</g>
</g>
<g class="eye_group">
<g id="Eye_Group_R" class="innerGroup">
<rect id="Eye_R" x="170" y="80" width="36" height="36" rx="18" fill="white" />
<rect id="Pupil_R" x="172" y="86" width="14" height="14" rx="7" fill="#424242" />
</g>
</g>
<g id="decorations" clip-path="url(#clip0_0_3)">
<path id="Ellipse 4" d="M219 149C219 150.498 218.1 152.323 215.573 154.319C213.065 156.301 209.257 158.195 204.269 159.827C199.301 161.453 193.36 162.756 186.779 163.648C180.201 164.54 173.139 165 166 165C158.861 165 151.799 164.54 145.221 163.648C138.64 162.756 132.699 161.453 127.731 159.827C122.743 158.195 118.935 156.301 116.427 154.319C113.9 152.323 113 150.498 113 149" stroke="#EE9D84" stroke-width="4" stroke-linecap="round" />
<path id="Ellipse 5" d="M219 203C219 204.498 218.1 206.323 215.573 208.319C213.065 210.301 209.257 212.195 204.269 213.827C199.301 215.453 193.36 216.756 186.779 217.648C180.201 218.54 173.139 219 166 219C158.861 219 151.799 218.54 145.221 217.648C138.64 216.756 132.699 215.453 127.731 213.827C122.743 212.195 118.935 210.301 116.427 208.319C113.9 206.323 113 204.498 113 203" stroke="#EE9D84" stroke-width="4" stroke-linecap="round" />
<path id="Ellipse 6" d="M219 257C219 258.498 218.1 260.323 215.573 262.319C213.065 264.301 209.257 266.195 204.269 267.827C199.301 269.453 193.36 270.756 186.779 271.648C180.201 272.54 173.139 273 166 273C158.861 273 151.799 272.54 145.221 271.648C138.64 270.756 132.699 269.453 127.731 267.827C122.743 266.195 118.935 264.301 116.427 262.319C113.9 260.323 113 258.498 113 257" stroke="#EE9D84" stroke-width="4" stroke-linecap="round" />
</g>
</g>
<defs>
<clipPath id="clip0_0_3">
<rect width="102" height="144" fill="white" transform="translate(115 131)" />
</clipPath>
</defs>
</svg>
body {
background-color: rgb(36, 89, 28);
background: linear-gradient(
0deg,
rgba(36, 89, 28, 1) 0%,
rgba(36, 89, 28, 1) 36%,
rgba(255, 255, 255, 1) 36%,
rgba(255, 255, 255, 1) 100%
);
height: 100vh;
overflow: hidden;
display: flex;
justify-content: center;
align-items: flex-end;
}
.innerGroup {
transform-box: fill-box;
transform-origin: center;
}
.eye_group {
transform-box: fill-box;
transform-origin: 50% 65%;
animation: blinkAnim 3000ms linear infinite;
}
.innerGroup rect:first-of-type {
animation: blackAnim 3000ms linear infinite;
}
#Smile {
transform-box: fill-box;
transform-origin: center;
animation: smileAnim 3000ms linear infinite;
}
@keyframes smileAnim {
0% {
transform: translateY(0);
}
88% {
transform: translateY(0);
}
90% {
transform: translateY(5%);
}
95% {
transform: translateY(-10%);
}
100% {
transform: translateY(0);
}
}
@keyframes blinkAnim {
0% {
transform: scaleY(1);
}
88% {
transform: scaleY(1);
}
90% {
transform: scaleY(1.1);
}
93% {
transform: scaleY(0.05);
}
97% {
transform: scaleY(0.05);
}
100% {
transform: scaleY(1);
}
}
@keyframes blackAnim {
0% {
fill: white;
}
90% {
fill: white;
}
93% {
fill: #424242;
}
97% {
fill: #424242;
}
100% {
fill: white;
}
}
@media only screen and (max-width: 600px) {
svg {
transform: scale(1.1);
}
}
function moveFunc(e) {
let box = document.querySelector("#Eye_Group_L");
let rightBox = document.querySelector("#Eye_Group_R");
let boxBoundingRect = box.getBoundingClientRect();
let boxCenter = {
x: boxBoundingRect.left + boxBoundingRect.width / 2,
y: boxBoundingRect.top + boxBoundingRect.height / 2
};
let angle =
Math.atan2(e.pageX - boxCenter.x, -(e.pageY - boxCenter.y)) *
(180 / Math.PI);
box.style.transform = `rotate(${angle + 60}deg)`;
rightBox.style.transform = box.style.transform;
}
window.scrollTo({
right: 0,
top: document.body.scrollHeight,
behavior: "smooth"
});
Also see: Tab Triggers