Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <input type="checkbox" id="debug" />

<ul class="cards" id="cards">
    <li id="card_0">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Front-1024x1024.jpg" width="1200" height="1200" />
    </li>
    <li id="card_1">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--A-Thousand-Clouds-Front-Cover-1024x1024.jpg" width="1200" height="1200" />
    </li>
    <li id="card_2">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Odd-World-EP-SMALL-1024x1024.png" width="1200" height="1200" />
    </li>
    <li id="card_3">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Forest-Blue-Pre-LR-1024x1024.png" width="1200" height="1200" />
    </li>
    <li id="card_4">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--MOM-Remixes-1024x1024.jpg" width="1200" height="1200" />
    </li>
    <li id="card_5">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--ALONE-TOGETHER-remix-V71-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_6">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Nature-Therapy-Pre-LR-550x550.png" width="1200" height="1200" />
    </li>
    <li id="card_7">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Deep-Dive-Ambient-Edits-V8-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_8">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Alpine-Koresma-x-Aroth-Artwork-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_9">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Out-Of-the-Dark-Cover-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_11">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--2020-06-07-Marley-Carroll-Single-Blue-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_12">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Deep-Dive-EP-Cover-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_13">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Blackrose-Cover-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_14">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--FW-Imagine-Gold-Remixes2-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_15">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--We-Are-COVER-MAIN-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_16">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Bath-House-Flat-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_17">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Pronoia-JPG-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_18">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Lapa9Theory-Cracking-Stores-no-Loci-logo-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_19">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--EMANCIPATOR_MOM_AlbumCover-2000px-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_20">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--MURGE-ep-cvr-3000x3000-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_21">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--Emancipator_Laybrinth-ART-01-4000x4000-at-300dpi-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_22">
        <img draggable="false" src="https://assets.codepen.io/89905/coverflow--cover-550x550.jpg" width="1200" height="1200" />
    </li>
</ul>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

:root {
  --cover-size: 15rem;
}

@media (max-width: 800px) {
	:root {
  		--cover-size: 9rem;
	}
}

@media (max-width: 600px) {
	:root {
  		--cover-size: 6rem;
	}
}

body {
  background: #111;
  min-height: 100vh;
  font-family: sans-serif;

  display: flex;
  place-items: center;
}

.cards {
  list-style: none;
  overflow-x: scroll;
  width: 100%;
  white-space: nowrap;

  scroll-snap-type: x mandatory;
  outline: 1px solid #333;
  background: rgba(0 0 0 / 0.5);
}

.cards li {
  display: inline-block;
  width: var(--cover-size);
  height: var(--cover-size);
  scroll-snap-align: center;
}

.cards li img {
  dislay: block;
  width: var(--cover-size);
  height: var(--cover-size);
	
  -webkit-box-reflect: below 0.5em linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.25));
}

.cards {
  max-width: calc(var(--cover-size) * 6);
  margin: 0 auto;
  padding: calc(var(--cover-size) / 3 * 2) calc(50% - (var(--cover-size) / 3 * 2));
}

/* Show warning for older browser */
.warning {
  position: fixed;
  bottom: 1em;
  right: 1em;
  left: 1em;
  padding: 1em;
  border: 1px solid black;
  z-index: 9999;
  text-align: center;
  color: black;
  background: rgba(255 255 225 / 0.9);
	display: none;
}

.warning a {
  color: blue;
}

#debug {
  position: absolute;
  top: 1em;
  left: 1em;
}
#debug::after {
  content: " Show Debug";
  margin-left: 1.5em;
  color: white;
  white-space: nowrap;
}

#debug:checked + .cards {
  border: 1px solid lime;
}

#debug:checked + .cards li {
  text-align: center;
  color: white;
  border: 1px solid blue;
}

#debug:checked + .cards li::before {
  content: attr(id);
  display: block;
  position: absolute;
  inset: 0;
  line-height: var(--cover-size);
  opacity: 0.5;
}

#debug:checked + .cards li img {
  opacity: 0.5;
}
              
            
!

JS

              
                // Alternative Versions:
// - JS ScrollTimeline 2022: https://codepen.io/bramus/pen/MWVExQg 👈 = The version you are currently looking at
// - CSS view-timeline 2022: https://codepen.io/bramus/pen/GRdGoKy/ 
// - JS Motion One: https://codepen.io/bramus/pen/PoRKEaZ 
// - (Old) CSS @scroll-timeline 2021: https://codepen.io/bramus/pen/xxRZZdK
// - (Old) JS ScrollTimeline 2021: https://codepen.io/bramus/pen/PobZbBV

import "https://rawcdn.githack.com/flackr/scroll-timeline/55c54c10ccf3308f36c09cbca4935286fe99f14f/dist/scroll-timeline.js";

const $ul = document.querySelector('ul');
const $lis = document.querySelectorAll('ul > li');

$lis.forEach(($li) => {

	$li.style.perspective = '40em';
	$li.style.position = 'relative';
	
	const viewTimeline = new ViewTimeline({
		subject: $li,
		axis: 'inline',
	});
	
	// Animate <li>
	$li.animate(
		{
			zIndex: ["1", "100", "1000", "100", "1"],
		},
		{
			timeline: viewTimeline,
			fill: 'both',
			// timeRange: 'contain',
			// delay: { phase: "contain", percent: CSS.percent(0) },
			// endDelay: { phase: "contain", percent: CSS.percent(100) }
		}
	);
	
	// Animate nested <img>
	$li.querySelector('img').animate(
		{
			transform: [
				'rotateY(-45deg) translateX(-100%)',
				'rotateY(-45deg) translateX(0)',
				'rotateY(0deg) translateZ(1em) scale(1.5)',
				'rotateY(45deg) translateX(0)',
				'rotateY(45deg) translateX(100%)',
			],
		},
		{
			timeline: viewTimeline,
			fill: 'both',
			// timeRange: 'contain',
			// delay: { phase: "contain", percent: CSS.percent(0) },
			// endDelay: { phase: "contain", percent: CSS.percent(100) }
		}
	);

});
              
            
!
999px

Console