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="cassette" style="--leftSpoolWidth:0.97">
<pre><strong>ArtLung Mix</strong> (2024)
by Joe Crawford</pre>
</div>
html {
height: 100%;
}
body {
height: 100%;
background-image: linear-gradient(lightblue 98vh,blue);
display: flex;
margin: 10px;
gap: 10px;
flex-wrap: wrap;
justify-content: center;
align-content: center;
overflow: hidden;
}
:root {
--angleAfter: 10deg;
--angleBefore: 30deg;
}
.cassette {
width: 450px;
min-width: 450px;
aspect-ratio: 20 / 13;
--bgColor: transparent;
--cassetteColor: #191919;
--accentColor: #ccc;
--darkAccentColor: #454545;
--leftSpoolWidth: 0.98;
--rightSpoolWidth: calc(1.0 - var(--leftSpoolWidth));
position: relative;
background-color: var(--bgColor);
background-repeat: no-repeat;
background-position:
50% 176px,
left 50% top 95px,
left 50% top 235px,
5px 5px,
right 5px top 5px,
right 5px bottom 5px,
left 5px bottom 5px,
bottom 4px left 50%,
bottom 4px left 50%,
bottom 4px right 50%,
/* corners */
5px 5px,
right 5px top 5px,
right 5px bottom 5px,
left 5px bottom 5px,
/* corners */
0px 183px,
right 0px top 183px,
right 0px bottom 26px,
left 0px bottom 26px,
/* top blocks */
left 15px top 5px,
left 5px top 18px,
/* holes */
left 5px top 86px,
right 5px top 86px,
left 0 top 190px,
left 5px top 38px,
right 5px top 38px,
/* smaller holes */
left 10px bottom 5px,
left 160px bottom 7px,
right 10px bottom 5px,
right 160px bottom 7px,
left 50% bottom 3px,
left 50% bottom 5px,
left 50% bottom 102px,
left 10px bottom 5px,
left 160px bottom 7px,
right 10px bottom 5px,
right 160px bottom 7px,
left 50% top 86px,
left 50% top 86px,
left 25px top 33px,
right 25px top 33px,
left 25px top 81px,
right 25px top 81px,
left 50% top 38px,
left -33px top -14px,
right -33px top -14px,
left 50% top 95px
;
background-size:
400px 37px,
110px 75px,
20px 20px,
20px 20px,
20px 20px,
20px 20px,
20px 20px,
272px 70px,
316px 70px,
316px 70px,
20px 20px,
20px 20px,
20px 20px,
20px 20px,
20px 20px,
20px 20px,
20px 20px,
20px 20px,
420px 20px,
440px 20px,
160px 100px,
160px 100px,
450px 72px,
25px 240px,
25px 240px,
150px 30px,
30px 30px,
150px 30px,
30px 30px,
316px 6px,
80px 30px,
390px 4px,
150px 30px,
30px 30px,
150px 30px,
30px 30px,
120px 100px,
120px 100px,
10px 10px,
10px 10px,
10px 10px,
10px 10px,
400px 48px,
300px 300px,
300px 300px,
110px 75px
;
background-image:
repeating-linear-gradient(
var(--darkAccentColor) 0 1px,
var(--cassetteColor) 1px 2px
),
conic-gradient(from 34deg at 20px 65px,transparent,rgba(255,255,255,0.6),rgba(255,255,255,0.1),transparent),
radial-gradient(var(--darkAccentColor),var(--cassetteColor) 10px,#0000 0),
radial-gradient(var(--darkAccentColor),var(--cassetteColor) 10px,#0000 0),
radial-gradient(var(--darkAccentColor),var(--cassetteColor) 10px,#0000 0),
radial-gradient(var(--darkAccentColor),var(--cassetteColor) 10px,#0000 0),
radial-gradient(var(--darkAccentColor),var(--cassetteColor) 10px,#0000 0),
linear-gradient(var(--darkAccentColor),transparent 3px),
linear-gradient(75deg,transparent 300px,var(--darkAccentColor) 303px,transparent 305px),
linear-gradient(-75deg,transparent 300px,var(--darkAccentColor) 303px,transparent 305px),
radial-gradient(circle,var(--cassetteColor) 10px, #0000 0),
radial-gradient(circle,var(--cassetteColor) 10px, #0000 0),
radial-gradient(circle,var(--cassetteColor) 10px, #0000 0),
radial-gradient(circle,var(--cassetteColor) 10px, #0000 0),
radial-gradient(circle,var(--cassetteColor) 10px, #0000 0),
radial-gradient(circle,var(--cassetteColor) 10px, #0000 0),
radial-gradient(circle,var(--cassetteColor) 10px, #0000 0),
radial-gradient(circle,var(--cassetteColor) 10px, #0000 0),
linear-gradient(var(--cassetteColor),var(--cassetteColor)),
linear-gradient(var(--cassetteColor),var(--cassetteColor)),
radial-gradient(circle at 70%,transparent 24px,var(--cassetteColor) 0),
radial-gradient(circle at 30%,transparent 24px,var(--cassetteColor) 0),
linear-gradient(var(--cassetteColor),var(--cassetteColor)),
linear-gradient(var(--cassetteColor),var(--cassetteColor)),
linear-gradient(var(--cassetteColor),var(--cassetteColor)),
radial-gradient(circle at 85% 18px,transparent 8px,var(--cassetteColor) 0),
radial-gradient(circle,transparent 8px,var(--cassetteColor) 0),
radial-gradient(circle at 15% 18px,transparent 8px,var(--cassetteColor) 0),
radial-gradient(circle,transparent 8px,var(--cassetteColor) 0),
linear-gradient(var(--cassetteColor),var(--cassetteColor)),
linear-gradient(var(--cassetteColor),var(--cassetteColor)),
linear-gradient(var(--cassetteColor),var(--cassetteColor)),
radial-gradient(circle at 87% 12px,transparent 8px,var(--darkAccentColor) 0),
radial-gradient(circle at 60% 30%,transparent 8px,var(--darkAccentColor) 0),
radial-gradient(circle at 13% 12px,transparent 8px,var(--darkAccentColor) 0),
radial-gradient(circle at 40% 30%,transparent 8px,var(--darkAccentColor) 0),
linear-gradient(var(--cassetteColor) 10px,transparent 10px 84px,var(--cassetteColor) 84px),
linear-gradient(90deg,var(--cassetteColor) 5px,transparent 5px 115px,var(--cassetteColor) 0),
radial-gradient(circle at 100% 100%, transparent 5px, var(--cassetteColor) 0),
radial-gradient(circle at 0% 100%, transparent 5px, var(--cassetteColor) 0),
radial-gradient(circle at 100% 0%, transparent 5px, var(--cassetteColor) 0),
radial-gradient(circle at 0% 0%, transparent 5px, var(--cassetteColor) 0),
/* label */
linear-gradient(#888 6px,#efefef 6px 23px,#666 23px 24px, #efefef 24px 42px,#888 0),
radial-gradient(circle,transparent 20px,
#eee 20px 56px,#3e2d06 56px calc(56px + 55px * var(--leftSpoolWidth)), transparent 0),
radial-gradient(circle,transparent 20px,
#eee 20px 56px,#3e2d06 56px calc(56px + 55px * var(--rightSpoolWidth)), transparent 0),
linear-gradient(var(--darkAccentColor) 4px,transparent 4px 70px,var(--darkAccentColor) 70px,#000)
;
}
.cassette::after,.cassette::before {
content: '';
display: block;
width: 48px;
height: 48px;
background-position: left 0 top 50%,left 50% top 0;
background-size: 38px 8px,8px 38px;
background-repeat: repeat-x,repeat-y;
background-image:
linear-gradient(90deg,#eee 10px, transparent 0),
linear-gradient(#eee 10px, transparent 0)
;
position: absolute;
}
.cassette::after {
transform: rotate(var(--angleAfter));
animation: rotateAfter 3.5s linear infinite;
top: 112px;
left: 93px;
}
.cassette[data-autoreverse="true"]::after {
animation: rotateAfterReverse 3.5s linear infinite;
}
.cassette::before {
transform: rotate(var(--angleBefore));
animation: rotateBefore 3.5s linear infinite;
top: 112px;
right: 93px;
}
.cassette[data-autoreverse="true"]::before {
animation: rotateBeforeReverse 3.5s linear infinite;
}
.cassette pre {
font-family: 'Courier New', 'Courier', monospace;
margin: 0;
background: transparent;
position: absolute;
line-height: 1.3;
color: #222;
top: 42px;
left: 32px;
width: 386px;
height: 42px;
overflow: hidden;
}
@keyframes rotateAfterReverse {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
@keyframes rotateBeforeReverse {
0% {
transform: rotate(10deg);
}
100% {
transform: rotate(369deg);
}
}
@keyframes rotateAfter {
0% {
transform: rotate(359deg);
}
100% {
transform: rotate(0deg);
}
}
@keyframes rotateBefore {
0% {
transform: rotate(369deg);
}
100% {
transform: rotate(10deg);
}
}
/* we count down from 1 to 0, then autoreverse 0 to 1 */
let Cassette = {
elem: null,
increment: 0.009,
ms: 750,
maxValue: 1.0,
minValue: 0.0,
varName: '--leftSpoolWidth',
currentValue: 0.5,
autoReverse: false,
setCurrentValue: function(v) {
this._currentValue = parseFloat(v);
return this;
},
getNewValue: function() {
let newValue;
if (this.autoReverse) {
newValue = this._currentValue + this.increment;
} else {
newValue = this._currentValue - this.increment;
}
if (this.autoReverse) {
if (newValue > this.maxValue) {
this.autoReverse = false;
this.elem.setAttribute('data-autoreverse', false);
}
} else {
if (newValue < this.minValue) {
this.autoReverse = true;
this.elem.setAttribute('data-autoreverse', true);
}
}
return [this.varName, newValue].join(':');
}
};
Cassette.elem = document.querySelector('.cassette');
setInterval(function() {
let currentStyle = Cassette.elem.getAttribute('style');
Cassette.elem.setAttribute('style', Cassette
.setCurrentValue(currentStyle.split(':')[1])
.getNewValue());
}, Cassette.ms);
Also see: Tab Triggers