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 class="snow-peng" viewBox="0 0 1000 700">
<g class="peng">
<g class="peng-boing" style="transform-origin:131px 425px">
<g class="peng-slide">
<g class="peng-flip">
<g class="peng-body" style="transform-origin:131px 171px">
<rect class="peng-foot peng-3" x="71.208" y="399" width="55" height="25" rx="12" style="transform-origin:125px 412px"/>
<path class="peng-1" d="M140 122h20a140 140 0 01140 140v25a125 125 0 01-125 125h-50A125 125 0 010 287v-25a140 140 0 01140-140z"/>
<ellipse class="peng-2" cx="99.208" cy="271" rx="89" ry="112"/>
<path class="peng-arm peng-4" d="M241.555 295.333l19.548-59.76a6.54 6.54 0 00-6.216-8.573h-51.96a6.54 6.54 0 00-6.215 8.573l19.547 59.76c4 12.227 21.297 12.227 25.296 0z" style="transform-origin:224px 219px"/>
<rect class="peng-foot peng-5" x="152.208" y="400" width="55" height="25" rx="12" style="transform-origin:207px 412px"/>
</g>
<g class="peng-head" style="transform-origin:159px 170px">
<path class="peng-1" d="M147.222 0h5.556A122.222 122.222 0 01275 122.222 97.778 97.778 0 01177.222 220h-54.444A97.778 97.778 0 0125 122.222 122.222 122.222 0 01147.222 0z"/>
<path class="peng-2" d="M126.201 38.279l-19.185 67.298a5.595 5.595 0 01-10.615 0L79.425 46.03C47.982 59.605 26.208 88.964 26.208 123c0 46.944 41.414 85 92.5 85s92.5-38.056 92.5-85c0-44.626-37.425-81.216-85.007-84.721z"/>
<ellipse class="peng-6" cx="38.208" cy="123" rx="12" ry="8"/>
<ellipse class="peng-6" cx="168.208" cy="123" rx="14" ry="8"/>
<ellipse class="peng-7" cx="158.708" cy="107.5" rx="9.5" ry="13.5"/>
<ellipse class="peng-7" cx="46.708" cy="107.5" rx="9.5" ry="13.5"/>
<rect class="peng-3" x="84.208" y="109" width="31" height="25" rx="12"/>
<rect class="peng-5" x="67.208" y="103" width="48" height="25" rx="12"/>
</g>
<g class="peng-scarf" style="transform-origin:159px 145px">
<g class="peng-scarf-under" style="transform-origin:257px 210px">
<rect class="peng-8" x="202.19" y="177.682" width="106" height="70" rx="20" transform="rotate(80 255.19 212.682)"/>
<path class="peng-8" d="M287.928 246.26l5.21 29.545-3.94.695-5.21-29.545zM272.171 249.039l5.21 29.544-3.94.695-5.209-29.544zM256.414 251.817l5.21 29.545-3.94.694-5.21-29.544zM240.657 254.596l5.21 29.544-3.94.694-5.21-29.544z"/>
</g>
<rect class="peng-scarf-main peng-9" y="151.5" width="300" height="70" rx="20" style="transform-origin:300px 190px"/>
</g>
</g>
</g>
</g>
</g>
</svg>
body {
display: flex;
align-items: center;
height: 100vh;
}
$ptl1: 1s;
$ptl1-half: 0.2s; // 1.2s
$ptl2-delay: 1.4s;
$ptl3: 1.1s;
$ptl3-delay: 2.5s;
$ptl4-delay: 2.6s;
$ptl5-delay: 3.4s;
.snow-peng {
width: 100%;
animation: floatDown $ptl1 forwards;
transform-origin: center bottom;
}
.peng {
animation: sliding 5s $ptl5-delay infinite alternate ease-out;
&-flip {
animation: flipper 10s $ptl5-delay infinite;
}
&-boing {
animation: boing $ptl1-half $ptl1 forwards;
}
&-slide {
transform: translateX(350px);
transform-origin: bottom center;
animation: slidingLeft $ptl3 $ptl3-delay ease-out forwards;
}
&-scarf-under {
animation: windy 0.3s $ptl4-delay infinite;
}
&-foot {
animation: footMove 1s $ptl4-delay infinite;
}
&-arm {
animation: armMove 2s $ptl4-delay infinite;
}
&-body {
animation: toSlidePosBody 1s $ptl2-delay forwards;
}
&-head {
animation: toSlidePosHead 1s $ptl2-delay forwards;
}
&-scarf {
&-main {
animation: toSlidePosScarfMain 1s $ptl2-delay forwards;
}
animation: toSlidePosScarf 1s $ptl2-delay forwards;
}
}
.peng-1 { fill: #bde7ff; }
.peng-2 { fill: #fff; }
.peng-3 { fill: #db6a1f; }
.peng-4 { fill: #95dbf9; }
.peng-5 { fill: #ff8931; }
.peng-6 { fill: #ff5086; opacity: 0.3; }
.peng-7 { fill: #444; }
.peng-8 { fill: #db4242; }
.peng-9 { fill: #ff5252; }
@keyframes floatDown {
0% { transform: translateY(-100%) }
100% { transform: translateY(0) }
}
@keyframes boing {
0% { transform: scaleY(0.8) }
40% { transform: scaleY(1.05) }
70% { transform: scaleY(0.95) }
100% { transfrom: scaleY(1) }
}
@keyframes slidingLeft {
0% { transform: translateX(350px) }
99.9% { transform: translateX(-420px) }
100% { transform: translateX(0) }
}
@keyframes toSlidePosBody {
100% { transform: rotate(-80deg) }
}
@keyframes toSlidePosHead {
100% { transform: rotate(-28deg) }
}
@keyframes toSlidePosScarfMain {
100% { transform: scaleX(0.95) }
}
@keyframes toSlidePosScarf {
100% { transform: rotate(-44deg) }
}
@keyframes sliding {
0% { transform: translateX(-420px); }
100% { transform: translateX(1420px); }
}
@supports (offset-path: path('M0,100')) {
@keyframes sliding {
0%, 100% { offset-path: path('M-520,210S-171.6634,10,141.4481,10,540.6654,158.7677,802.8963,158.7677,1200.1566,54.9183,1480,54.9183') }
100% { offset-distance: 100%; }
}
}
@keyframes flipper {
0%, 49.9% { transform: rotateY(180deg) scale(0.6) }
50%, 100% { transform: rotateY(0deg) translateY(100px) }
}
@keyframes windy {
20% { transform: rotate(-10deg) }
40% { transform: rotate(0deg) }
60% { transform: rotate(5deg) }
80% { transform: rotate(-5deg) }
100% { transform: rotate(0deg) }
}
@keyframes footMove {
33% { transform: translateY(-20px) rotate(-90deg) }
66% { transform: translateY(-20px) rotate(-107deg) }
0%, 100% { transform: translateY(-20px) rotate(-100deg) }
}
@keyframes armMove {
0%, 100% { transform: translateY(50px) rotate(-70deg) }
50% { transform: translateY(50px) rotate(-50deg) }
}
Also see: Tab Triggers