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.
<div class="slideshow">
<figure>
<!-- self-referenced link -->
<a id="a-classic" href="#a-classic">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/A classic.jpg" alt="A classic" title="A classic">
</a>
</figure>
<figure>
<a id="a-taste-of-italy" href="#a-taste-of-italy">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/A taste of Italy.jpg" alt="A taste of Italy" title="A taste of Italy">
</a>
</figure>
<figure>
<a id="apple-pie-exit" href="#apple-pie-exit">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Apple pie exit.jpg" alt="Apple pie exit" title="Apple pie exit">
</a>
</figure>
<figure>
<a id="aztec-motel" href="#aztec-motel">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Aztec motel.jpg" alt="Aztec motel" title="Aztec motel">
</a>
</figure>
<figure>
<a id="ballroom-entrance" href="#ballroom-entrance">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Ballroom entrance.jpg" alt="Ballroom entrance" title="Ballroom entrance">
</a>
</figure>
<figure>
<a id="best-of-both-worlds" href="#best-of-both-worlds">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Best of both worlds.jpg" alt="Best of both worlds" title="Best of both worlds">
</a>
</figure>
<figure>
<a id="big-fish" href="#big-fish">
<img loading="lazy" width="961" height="649" src="https://cadars.github.io/photosheet/img/john-margolies/Big fish.jpg" alt="Big fish" title="Big fish">
</a>
</figure>
<figure>
<a id="budget-knight" href="#budget-knight">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Budget knight.jpg" alt="Budget knight" title="Budget knight">
</a>
</figure>
<figure>
<a id="buffalo" href="#buffalo">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Buffalo.jpg" alt="Buffalo" title="Buffalo">
</a>
</figure>
<figure>
<a id="car-wash" href="#car-wash">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Car wash.jpg" alt="Car wash" title="Car wash">
</a>
</figure>
<figure>
<a id="censored-king-kong" href="#censored-king-kong">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Censored King Kong.jpg" alt="Censored King Kong" title="Censored King Kong">
</a>
</figure>
<figure>
<a id="chicken-sign" href="#chicken-sign">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Chicken sign.jpg" alt="Chicken sign" title="Chicken sign">
</a>
</figure>
<figure>
<a id="concert-venue" href="#concert-venue">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Concert venue.jpg" alt="Concert venue" title="Concert venue">
</a>
</figure>
<figure>
<a id="concrete-teepees" href="#concrete-teepees">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Concrete teepees.jpg" alt="Concrete teepees" title="Concrete teepees">
</a>
</figure>
<figure>
<a id="dinosaur-village" href="#dinosaur-village">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Dinosaur village.jpg" alt="Dinosaur village" title="Dinosaur village">
</a>
</figure>
<figure>
<a id="eye" href="#eye">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Eye.jpg" alt="Eye" title="Eye">
</a>
</figure>
<figure>
<a id="flamingo" href="#flamingo">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Flamingo.jpg" alt="Flamingo" title="Flamingo">
</a>
</figure>
<figure>
<a id="fox-tower" href="#fox-tower">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Fox tower.jpg" alt="Fox tower" title="Fox tower">
</a>
</figure>
<figure>
<a id="hat-and-boots" href="#hat-and-boots">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Hat and boots.jpg" alt="Hat and boots" title="Hat and boots">
</a>
</figure>
<figure>
<a id="hoot-owl-cafe" href="#hoot-owl-cafe">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Hoot owl cafe.jpg" alt="Hoot owl cafe" title="Hoot owl cafe">
</a>
</figure>
<figure>
<a id="ko-ko-mo" href="#ko-ko-mo">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Ko ko mo.jpg" alt="Ko ko mo" title="Ko ko mo">
</a>
</figure>
<figure>
<a id="loch-ness-auto-shop" href="#loch-ness-auto-shop">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Loch Ness auto shop.jpg" alt="Loch Ness auto shop" title="Loch Ness auto shop">
</a>
</figure>
<figure>
<a id="motel" href="#motel">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Motel.jpg" alt="Motel" title="Motel">
</a>
</figure>
<figure>
<a id="moulin-vert" href="#moulin-vert">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Moulin Vert.jpg" alt="Moulin Vert" title="Moulin Vert">
</a>
</figure>
<figure>
<a id="neon-couch" href="#neon-couch">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Neon couch.jpg" alt="Neon couch" title="Neon couch">
</a>
</figure>
<figure>
<a id="neon-sign" href="#neon-sign">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Neon sign.jpg" alt="Neon sign" title="Neon sign">
</a>
</figure>
<figure>
<a id="psa" href="#psa">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/PSA.jpg" alt="PSA" title="PSA">
</a>
</figure>
<figure>
<a id="peach" href="#peach">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Peach.jpg" alt="Peach" title="Peach">
</a>
</figure>
<figure>
<a id="red-rooster-sign" href="#red-rooster-sign">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Red rooster sign.jpg" alt="Red rooster sign" title="Red rooster sign">
</a>
</figure>
<figure>
<a id="roadside-art" href="#roadside-art">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Roadside art.jpg" alt="Roadside art" title="Roadside art">
</a>
</figure>
<figure>
<a id="robot" href="#robot">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Robot.jpg" alt="Robot" title="Robot">
</a>
</figure>
<figure>
<a id="teapot-cabaret" href="#teapot-cabaret">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Teapot cabaret.jpg" alt="Teapot cabaret" title="Teapot cabaret">
</a>
</figure>
<figure>
<a id="trading-post" href="#trading-post">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Trading post.jpg" alt="Trading post" title="Trading post">
</a>
</figure>
<figure>
<a id="whale-garage" href="#whale-garage">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/Whale garage.jpg" alt="Whale garage" title="Whale garage">
</a>
</figure>
<figure>
<a id="white-rooster-sign" href="#white-rooster-sign">
<img loading="lazy" src="https://cadars.github.io/photosheet/img/john-margolies/White rooster sign.jpg" alt="White rooster sign" title="White rooster sign">
</a>
</figure>
<div class="counter"></div>
</div>
/*
Self-referenced links, #permalinks, native lazy loading.
Each link pseudo-elements bleed 50% into the previous and next slide, acting as prev/next buttons, supplementing scroll/swipe, Tab key (focus), and keyboard arrows.
Alas, the image counter doesn‘t update on scroll ¯\_(ツ)_/¯
*/
html,
body {
height: 100%;
}
.slideshow {
height: 100%;
overflow-x: scroll;
scroll-snap-type: x mandatory;
overscroll-behavior-x: contain;
display: flex;
gap: 4vw;
}
/* transition on :hover only so they don’t fire when opening a #permalink */
.slideshow:hover {
scroll-behavior: smooth;
/* `auto` for no transition on click/tab */
}
.slideshow figure {
position: relative;
scroll-snap-align: start;
flex-shrink: 0;
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
}
.slideshow figure a {
flex-shrink: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
-webkit-tap-highlight-color: transparent;
}
.slideshow a img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
z-index: 1; /* cover the loading spinner */
}
.slideshow a:focus-visible {
outline: 0;
}
/* Prev / Next */
.slideshow a:before,
.slideshow a:after {
z-index: 2; /* cover the current image <a> */
content: "";
display: block;
position: absolute;
top: 0;
bottom: 0;
width: calc(50% + 4vw); /* 50vw + 4vw gap */
}
.slideshow a:before {
left: calc(-1 * calc(50% + 4vw));
}
.slideshow a:after {
right: calc(-1 * calc(50% + 4vw));
}
.slideshow :first-child a:before,
.slideshow :last-child a:after {
display: none;
}
/* -- Loading spinner -- */
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.slideshow figure::after {
content: "";
height: 2em;
width: 2em;
animation: spin 0.8s infinite linear;
border: 1px solid;
border-right-color: transparent;
border-radius: 50%;
display: block;
position: absolute;
top: calc(50% - 1em);
right: calc(50% - 1em);
opacity: 0.4;
}
/* Counter */
.slideshow {
counter-reset: currentStep 0 remainder 0 totalStep 0;
}
.slideshow figure {
counter-increment: totalStep;
}
.slideshow figure::before {
content: "";
counter-increment: currentStep;
}
.slideshow figure:focus-within ~ figure::before {
counter-increment: remainder;
}
.slideshow:hover figure:focus-within ~ .counter {
z-index: 1;
font-variant-numeric: tabular-nums;
position: absolute;
bottom: 1em;
right: 1.5em;
text-shadow: 1px 1px 1px #000;
}
.slideshow .counter::before {
font-size: 0.9em;
content: counter(currentStep) " / " counter(totalStep);
}
/* Demo styles */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
a {
text-decoration: none;
color: currentColor;
}
body {
font: 16px system-ui, sans-serif;
background: #0e0e0f;
color: #fff;
}
Also see: Tab Triggers