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="intro">
<h1>Scroll down for hardware that stored data</h1>
</div>
<main>
<article class="stop">
<div class="text">
<header>
<h2>Magnetic drum</h2>
<time>1932</time> - Gustav Taushek
</header>
<p>A rotating cylinder coated with a magnetic material, used for storing data.</p>
<img src="https://assets.codepen.io/159218/drum-memory.jpg" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>Magnetic tape</h2>
<time>1951</time> - Fritz Pfleumer
</header>
<p>A long strip of plastic coated with a magnetic material, used for storing data.</p>
<img src="https://assets.codepen.io/159218/magnetic-tape.jpg" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>Hard disk drive</h2>
<time>1956</time> - IBM
</header>
<p>A stack of rotating platters coated with a magnetic material.</p>
<img src="https://assets.codepen.io/159218/hard-disk-drive.jpg" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>Floppy disk</h2>
<time>1967</time> - Alan Shugart
</header>
<p>A small, flexible disk coated with a magnetic material, used for storing data.</p>
<img src="https://assets.codepen.io/159218/floppy-disk.jpg" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>Compact cassette</h2>
<time>1971</time> - Philips
</header>
<p>A small, magnetic tape cassette used for storing data.</p>
<img src="https://assets.codepen.io/159218/compact-cassette.jpg" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>Zip drive</h2>
<time>1980</time> - Iomega
</header>
<p>A removable disk drive with a capacity of up to 100 MB.</p>
<img src="https://assets.codepen.io/159218/zip-drive.jpg" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>CD-ROM</h2>
<time>1984</time> - James Russell
</header>
<p>A compact disc that can store up to 700 MB of data.</p>
<img src="https://assets.codepen.io/159218/cd-rom.png" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>DVD-ROM</h2>
<time>1994</time> - Kenji Kashiwaya
</header>
<p>A digital versatile disc that can store up to 4.7 GB of data.</p>
<img src="https://assets.codepen.io/159218/dvd-rom.png" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>Blu-ray Disc</h2>
<time>1995</time> - Sony and Philips
</header>
<p>A high-definition optical disc that can store up to 25 GB of data.</p>
<img src="https://assets.codepen.io/159218/blu-ray.png" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>Solid-state drive</h2>
<time>2000</time> - SanDisk
</header>
<p>A type of storage device that uses flash memory to store data.</p>
<img src="https://assets.codepen.io/159218/ssd.jpg" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>USB flash drive</h2>
<time>2003</time> - IBM
</header>
<p> A small, portable storage device that uses flash memory to store data.</p>
<img src="https://assets.codepen.io/159218/usb-flash-drive.jpg" alt="" />
</div>
</article>
<article class="stop">
<div class="text">
<header>
<h2>Cloud storage</h2>
<time>2007</time> - Amazon Web Services
</header>
<p>A service that allows users to store data on remote servers.</p>
<img src="https://images.unsplash.com/photo-1517685352821-92cf88aee5a5?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODk2MDA3NDJ8&ixlib=rb-4.0.3&q=85" alt="" />
</div>
</article>
</main>
@import url("https://fonts.googleapis.com/css2?family=Open+Sans&family=Ubuntu:wght@500&display=swap");
@layer original, print;
@property --clip-vertical {
syntax: "<percentage>";
initial-value: 95%;
inherits: false;
}
@property --clip-horizontal {
syntax: "<percentage>";
initial-value: 100%;
inherits: false;
}
@property --intro-radial {
syntax: "<percentage>";
initial-value: 0%;
inherits: false;
}
@layer print {
@media print {
body {
font-size: 9pt;
color: black;
}
/* Intro doesn't matter for print */
.intro {
display: none;
}
main {
display: grid;
grid-template-columns: repeat(2, 1fr);
padding-block: 1cm;
}
main::before {
margin-left: -0.5mm;
border-right: 1mm dashed darkgray;
}
h1 {
font-size: 14pt;
margin-top: 3cm;
color: black;
}
.stop {
width: 100%;
opacity: 1;
padding-top: 50px;
min-height: 0;
animation: none;
margin: 0;
page-break-inside: avoid;
&:nth-child(odd) {
padding-left: 0;
}
&:nth-child(even) {
margin-left: 0;
margin-top: 5cm;
padding-right: 0;
}
& img {
max-width: 100px;
}
}
.text {
animation: none;
color: black;
border-color: gray;
box-shadow: none;
}
.stop::before,
.stop::after {
--clip-horizontal: 0%;
--clip-vertical: 0%;
animation: none;
border-color: darkgray;
}
.stop::after {
height: calc(50px - 20px);
}
}
}
@layer original {
main {
--timeline-width: 100%;
position: relative;
padding-block: 300px;
max-width: 1000px;
margin-inline: auto;
&::before {
position: absolute;
top: 0;
left: 50%;
width: 0;
height: 100%;
margin-left: -3px;
border-right: 6px dashed oklch(20% 0.5 313);
content: "";
}
}
.stop {
--clip-horizontal: 100%;
--clip-vertical: 93%;
position: relative;
min-height: 70vh;
padding-top: 15vh;
width: calc(var(--timeline-width) / 2);
padding-inline: 50px;
&::before {
position: absolute;
top: 0;
right: 0;
width: 40px;
height: 40px;
border-radius: 50%;
background: oklch(80% 0.23 68);
border: 6px solid oklch(20% 0.5 313);
content: "";
translate: 50% 0;
transform-origin: center;
animation: popIn linear both;
animation-timeline: view(block);
animation-range: cover 5% contain 22%;
}
&::after {
position: absolute;
top: 20px;
right: 40px;
width: 80%;
height: calc(15vh - 20px);
border-width: 3px 0 0 3px;
border-style: dashed;
border-color: oklch(20% 0.5 313);
clip-path: inset(0 0 var(--clip-vertical) var(--clip-horizontal));
transform-origin: center;
animation: showLine linear both;
animation-timeline: view(block);
animation-range: cover 10% contain 40%;
content: "";
}
&:nth-child(even) {
justify-content: flex-end;
text-align: end;
margin-left: calc(var(--timeline-width) / 2);
&::before {
right: auto;
left: 0;
translate: -50% 0;
}
&::after {
right: auto;
left: 40px;
border-width: 3px 3px 0 0;
clip-path: inset(0 var(--clip-horizontal) var(--clip-vertical) 0);
}
}
}
.text {
animation: slideIn linear both;
animation-timeline: view(block);
animation-range: cover 0% contain 12%;
}
/* keyframes */
@keyframes popIn {
0% {
scale: 0;
}
60% {
scale: 1.2;
}
}
@keyframes moveGradient {
to {
--intro-radial: 100%;
}
}
@keyframes showLine {
0% {
--clip-horizontal: 100%;
--clip-vertical: 95%;
}
60% {
--clip-horizontal: 0%;
--clip-vertical: 95%;
}
100% {
--clip-horizontal: 0%;
--clip-vertical: 0%;
}
}
@keyframes slideIn {
0% {
opacity: 0;
translate: 0 50%;
}
100% {
opacity: 1;
translate: 0 3%;
}
}
/* Default styles */
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
font-family: "Open Sans", sans-serif;
margin: 0;
padding: 0;
overflow-x: hidden;
font-size: 1rem;
line-height: 1.6;
background-image: radial-gradient(
150vw circle at var(--intro-radial) var(--intro-radial) in oklab,
oklch(80% 0.23 68) 0%,
oklch(35% 0.5 313) 100%
),
url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="28" height="49" viewBox="0 0 28 49"%3E%3Cg fill-rule="evenodd"%3E%3Cg id="hexagons" fill="%23444" fill-opacity="0.4" fill-rule="nonzero"%3E%3Cpath d="M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z"/%3E%3C/g%3E%3C/g%3E%3C/svg%3E');
background-size: 100%, 500px;
background-attachment: fixed;
background-color: #000;
background-blend-mode: difference;
animation: moveGradient linear both;
animation-timeline: view(block);
animation-range: contain 0% cover 100%;
}
h2 {
font-family: "Ubuntu", sans-serif;
font-weight: 500;
margin: 0;
}
header {
font-family: "Ubuntu", sans-serif;
font-weight: 500;
}
p {
margin-block: 1.2rem 0;
}
.text {
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(8px);
color: #fff;
padding: 1.1rem;
box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px,
rgba(0, 0, 0, 0.3) 0px 8px 16px -8px;
border: 1px solid oklch(38% 0.5 313);
border-radius: 0.6rem;
}
.intro {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
padding-inline: 30px;
height: 50vh;
color: white;
}
img {
width: 200px;
margin-block-start: 1.05rem;
border: 1px solid #eee;
background: white;
}
/* Some mobile improvements I did after the demo was finished :) I know this could be done a bit more optimised if i'd done it right away */
@media screen and (width <= 600px) {
main::before {
left: 30px;
margin-left: 0;
}
.stop,
.stop:nth-child(even) {
justify-content: flex-end;
text-align: end;
margin-bottom: 30px;
margin-left: 33px;
width: calc(var(--timeline-width) - 33px);
padding-inline: 30px 8px;
&::before {
right: auto;
left: 0;
translate: -50% 0;
}
&::after {
right: auto;
left: 40px;
border-width: 3px 3px 0 0;
clip-path: inset(0 var(--clip-horizontal) var(--clip-vertical) 0);
}
.text {
text-align: left;
}
}
}
}
/* This is a copy of a demo i used in: https://utilitybend.com/blog/scroll-driven-animations-in-css-are-a-joy-to-play-around-with
In case you are interested abou the scroll animation start there :) this was an extra example I re-used for print styles
*/
Also see: Tab Triggers