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="fish">
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
</div>
<div class="fish">
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
<div class="koiCoil"></div>
</div>
<div class="seaLevel"></div>
:root {
--coilSize: 14px;
--delayCount: 40ms;
--scaleMe: 1;
--scaleFlip: 1;
--posFlip: 0;
}
body,
.seaLevel {
font-family: "Open Sans", sans-serif;
background-color: lightblue;
overflow: hidden;
}
.fish {
position: absolute;
top: -35%;
left: 0;
width: 100%;
height: 100%;
filter: drop-shadow(
calc(var(--coilSize) * 4) calc(var(--coilSize) / 3) 5px rgba(0, 0, 0, 0.3)
);
}
.fish .koiCoil {
position: absolute;
width: var(--coilSize);
height: var(--coilSize);
background-color: orangered;
border-radius: 50%;
top: 50%;
left: 50%;
margin-left: calc(var(--coilSize) / -2);
margin-top: calc(var(--coilSize) / -2);
transform: scale(var(--scaleMe), var(--scaleMe));
filter: contrast(200%);
offset-path: path(
"M11.7692 229.5C14.552 200.052 7.51901 171.858 -42.8757 170.644C-105.869 169.128 -131.294 76.612 -101.695 51.5872C-72.0955 26.5625 -24.6607 -50.7867 70.5883 51.5872C165.837 153.961 27.7073 131.211 33.0199 183.157C38.3326 235.102 90.3211 195.669 139.274 223.727C188.226 251.785 207.959 299.56 139.274 316.243C70.5883 332.926 41.3685 398.9 81.9726 419.754C122.577 440.608 222 478.524 222 419.754C222 372.738 222 242.432 222 183.157C219.091 129.948 175.78 30.8091 25.8099 59.9288C-161.652 96.3284 -30.3529 119.837 25.8099 141.07C81.9726 162.303 171.529 204.769 126.751 260.506C81.9726 316.243 101.326 362.501 139.274 373.496C177.222 384.492 170.012 464.495 70.5883 462.979C-28.835 461.462 -42.8757 393.015 -42.8757 373.496C-42.8757 238.288 11.7692 293 11.7692 240.506C11.7692 208.05 11.7692 237.336 11.7692 229.5Z"
);
animation: fishAnim 20000ms linear infinite;
box-shadow: calc(var(--coilSize) / -2) calc(var(--coilSize) / -10) 0 white
inset;
}
.fish:nth-of-type(2) {
transform-origin: top center;
transform: scale(-1, 1);
filter: drop-shadow(
calc(var(--coilSize) * -4) calc(var(--coilSize) / 3) 5px rgba(0, 0, 0, 0.3)
);
}
.fish:nth-of-type(2) .koiCoil {
background-color: white;
box-shadow: calc(var(--coilSize) / -2) calc(var(--coilSize) / -10) 0 orangered
inset;
}
.fish .koiCoil:nth-of-type(15),
.fish .koiCoil:nth-of-type(14) {
background-color: orangered;
}
.fish:nth-of-type(2) .koiCoil:nth-of-type(15),
.fish:nth-of-type(2) .koiCoil:nth-of-type(14) {
background-color: white;
}
.fish .koiCoil:nth-of-type(15)::after {
content: ":";
position: absolute;
color: black;
font-weight: 800;
text-align: center;
line-height: 60%;
font-size: calc(var(--coilSize) * 1.2);
}
.fish .koiCoil:nth-of-type(1)::before {
content: "";
position: absolute;
width: 100%;
height: 50%;
top: 25%;
left: -100%;
border-radius: var(--coilSize);
background-color: white;
/*box-shadow: calc(var(--coilSize) / -10) calc(var(--coilSize) / -4) calc(var(--coilSize) / 3) rgba(0,0,0,.3) inset;*/
transform-origin: center right;
animation: backFlip 200ms ease-in-out alternate infinite;
}
.fish .koiCoil:nth-of-type(14) {
--scaleMe: 1.2;
animation-delay: calc(var(--delayCount) * 1);
}
.fish .koiCoil:nth-of-type(13) {
--scaleMe: 1.35;
animation-delay: calc(var(--delayCount) * 2);
}
.fish .koiCoil:nth-of-type(12) {
--scaleMe: 1.55;
animation-delay: calc(var(--delayCount) * 3);
}
.fish .koiCoil:nth-of-type(11) {
--scaleMe: 1.75;
animation-delay: calc(var(--delayCount) * 4);
}
.fish .koiCoil:nth-of-type(10) {
--scaleMe: 1.9;
animation-delay: calc(var(--delayCount) * 5);
}
.fish .koiCoil:nth-of-type(9) {
--scaleMe: 2;
animation-delay: calc(var(--delayCount) * 6);
}
.fish .koiCoil:nth-of-type(8) {
--scaleMe: 2;
animation-delay: calc(var(--delayCount) * 7);
}
.fish .koiCoil:nth-of-type(7) {
--scaleMe: 2;
animation-delay: calc(var(--delayCount) * 8);
}
.fish .koiCoil:nth-of-type(6) {
--scaleMe: 1.9;
animation-delay: calc(var(--delayCount) * 9);
}
.fish .koiCoil:nth-of-type(5) {
--scaleMe: 1.75;
animation-delay: calc(var(--delayCount) * 10);
}
.fish .koiCoil:nth-of-type(4) {
--scaleMe: 1.55;
animation-delay: calc(var(--delayCount) * 11);
}
.fish .koiCoil:nth-of-type(3) {
--scaleMe: 1.35;
animation-delay: calc(var(--delayCount) * 12);
}
.fish .koiCoil:nth-of-type(2) {
--scaleMe: 1.2;
animation-delay: calc(var(--delayCount) * 13);
}
.fish .koiCoil:nth-of-type(1) {
animation-delay: calc(var(--delayCount) * 14);
}
.fish .koiCoil:nth-of-type(12)::before,
.fish .koiCoil:nth-of-type(12)::after {
content: "";
position: absolute;
width: 100%;
height: 20%;
top: -10%;
left: -100%;
border-radius: var(--coilSize);
background-color: white;
transform-origin: center right;
animation: sideFlip 500ms ease-in-out alternate infinite;
}
.fish .koiCoil:nth-of-type(12)::after {
--scaleFlip: -1;
--posFlip: calc(var(--coilSize) * -1);
}
.seaLevel {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
opacity: 0.4;
}
@keyframes fishAnim {
0% {
offset-distance: 0%;
}
100% {
offset-distance: 100%;
}
}
@keyframes backFlip {
0% {
transform: rotate(45deg);
}
100% {
transform: rotate(-45deg);
}
}
@keyframes sideFlip {
0% {
transform: scale(1, var(--scaleFlip)) translateY(var(--posFlip))rotate(80deg);
}
100% {
transform: scale(1, var(--scaleFlip)) translateY(var(--posFlip))rotate(20deg);
}
}
/*This is experimental features,
WILL WORK IN CHROME ONLY*/
Also see: Tab Triggers