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.
main
.pan(ontouchstart)
.handle
.outer
.inner
.egg-wrapper
.egg
.yolk
p click & hold on the pan!
@import url(https://fonts.googleapis.com/css?family=Montserrat);
$color-bg: #f0ead6;
$color-pan: #080808;
$color-handle: #CDCDCD;
$color-egg: #ffffff;
$color-yolk: #f9d010;
html, body {
height: 100%;
padding: 0;
margin: 0;
}
body {
overflow: hidden;
background-color: $color-bg;
font-family: 'Montserrat', sans-serif;
box-shadow: inset rgba(black, 0.2) 0 0 100px 24px;
}
p {
position: absolute;
top: 12px;
left: 0;
margin: 0;
color: $color-bg;
background-color: darken($color-bg, 50%);
padding: 6px 20px;
text-transform: uppercase;
font-size: 12px;
line-height: 18px;
}
main {
display: flex;
justify-content: center;
align-items: center;
max-width: 800px;
height: 100%;
margin: auto;
}
.pan {
position: relative;
width: 40%;
border-radius: 100%;
animation: shakin 6s linear infinite;
&:after {
content: '';
display: block;
padding-bottom: 100%;
}
.outer {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
margin: auto;
background-color: $color-pan;
border-radius: 100%;
z-index: 2;
box-shadow: inset $color-pan 2px 4px 2px 2px,
inset rgba(white, 0.2) 2px 8px 12px 4px,
rgba($color-bg, 0.8) 4px 4px 12px 4px,
rgba(black, 0.4) 2px 4px 12px 2px;
}
.inner {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
margin: auto;
width: 70%;
height: 70%;
background-color: lighten($color-pan, 10%);
border-radius: 100%;
z-index: 3;
box-shadow: inset lighten($color-pan, 10%) 0 2px 4px 6px,
inset rgba(white, 0.1) 4px 6px 34px 4px,
$color-pan 0 0 0 10px,
rgba(white, 0.14) -4px -2px 4px 8px,
rgba(white, 0.14) 4px 2px 4px 8px;
}
}
.pan .handle {
position: absolute;
top: -35%;
right: -20%;
width: 16%;
height: 50%;
background-color: $color-pan;
transform: rotate(45deg);
z-index: 1;
border-radius: 30%;
box-shadow: inset $color-pan 2px 2px 4px 2px,
inset rgba(white, 0.2) 3px -8px 8px 10px,
rgba($color-bg, 0.8) 4px 32px 12px 4px,
rgba(black, 0.15) 6px 38px 12px 4px;
&:before {
content: '';
position: absolute;
bottom: -30%; right: 0;
width: 100%;
height: 50%;
background-color: $color-handle;
box-shadow: inset $color-handle 2px 2px 2px 8px,
inset rgba(white, 0.2) 4px -4px 6px 12px;
}
}
.egg {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
margin: auto;
background-color: $color-egg;
width: 40%;
height: 0;
padding-bottom: 38%;
z-index: 4;
border-radius: 50%;
box-shadow: inset $color-egg 4px 2px 6px 10px,
inset rgba(black, 0.2) 0 0 20px 8px;
animation: sizzlin 1.6s linear alternate infinite;
&:before, &:after {
content: '';
background-color: $color-egg;
position: absolute;
height: 0;
border-radius: 50%;
}
&:before {
top: -2px;
left: 4px;
width: 60%;
padding-bottom: 60%;
box-shadow: inset $color-egg -2px -12px 4px 6px,
inset rgba(black, 0.1) 2px 0px 12px 4px;
}
&:after {
bottom: 2px;
right: 2px;
width: 70%;
padding-bottom: 70%;
box-shadow: inset $color-egg 12px 12px 4px 6px,
inset rgba(black, 0.1) -6px 0px 12px 4px;
}
.yolk {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
margin: auto;
background-color: $color-yolk;
width: 50%;
height: 0;
padding-bottom: 50%;
z-index: 5;
border-radius: 100%;
box-shadow: inset $color-yolk 0 0 0 4px,
inset rgba(white, 0.3) 2px 2px 4px 6px,
inset $color-yolk 2px 2px 4px 16px,
inset rgba(white, 0.3) -2px -2px 12px 12px,
rgba(black, 0.05) 0 0 2px 2px;
}
}
.egg-wrapper {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
margin: auto;
z-index: 5;
animation: movin 6s linear infinite;
}
.pan {
cursor: pointer;
-webkit-user-select: none;
-webkit-touch-callout: none;
&:active {
animation: push 0.6s ease-out;
.egg-wrapper {
animation: pop 0.5s 0.14s ease-out;
}
}
}
@keyframes sizzlin {
0% {
transform: rotate(0)
scale(0.98);
}
10% {
transform: rotate(0)
scale(1.01);
}
20% {
transform: rotate(2deg)
scale(0.997);
}
25% {
transform: rotate(2deg)
scale(0.998);
}
30% {
transform: rotate(2deg)
scale(1.01);
}
40% {
transform: rotate(-2deg)
scale(0.995);
}
50% {
transform: rotate(-2deg)
scale(1);
}
60% {
transform: rotate(-3deg)
scale(0.996);
}
80% {
transform: rotate(1deg)
scale(1);
}
90% {
transform: rotate(1deg)
scale(0.997);
}
100% {
transform: rotate(0deg)
scale(1);
}
}
@keyframes movin {
0% {
transform: translate(0,0);
}
4% {
transform: translate(8px,-8px);
}
6% {
transform: translate(0,0);
}
7% {
transform: translate(-4px,4px);
}
12% {
transform: translate(0,0);
}
100% {
transform: translate(0,0);
}
}
@keyframes shakin {
0% {
transform: translate(0,0);
}
2% {
transform: translate(-12px,12px);
}
4% {
transform: translate(0,0);
}
6% {
transform: translate(-6px,6px);
}
8% {
transform: translate(0,0);
}
100% {
transform: translate(0,0);
}
}
@keyframes push {
0% {
transform: scale(1)
translateZ(0);
}
25% {
transform: scale(0.9)
translateZ(0);
}
50% {
transform: scale(1.04)
translateZ(0);
}
100% {
transform: scale(1)
translateZ(0);
}
}
@keyframes pop {
0% {
transform: rotate(0)
scale(1)
translateZ(0);
}
50% {
transform: rotate(20deg)
scale(1.4)
translateZ(0);
}
80% {
transform: rotate(0)
scale(0.8)
translateZ(0);
}
100% {
transform: rotate(0)
scale(1)
translateZ(0);
}
}
Also see: Tab Triggers