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

              
                <script src="https://rawcdn.githack.com/flackr/scroll-timeline/637746fa559c3f9d01fcdaf2fcb7e649d18dfc33/dist/scroll-timeline.js"></script>
<input type="checkbox" id="debug" />

<ul class="cards" id="cards">
    <li id="card_0">
        <img src="https://assets.codepen.io/89905/coverflow--Front-1024x1024.jpg" width="1200" height="1200" />
    </li>
    <li id="card_1">
        <img src="https://assets.codepen.io/89905/coverflow--A-Thousand-Clouds-Front-Cover-1024x1024.jpg" width="1200" height="1200" />
    </li>
    <li id="card_2">
        <img src="https://assets.codepen.io/89905/coverflow--Odd-World-EP-SMALL-1024x1024.png" width="1200" height="1200" />
    </li>
    <li id="card_3">
        <img src="https://assets.codepen.io/89905/coverflow--Forest-Blue-Pre-LR-1024x1024.png" width="1200" height="1200" />
    </li>
    <li id="card_4">
        <img src="https://assets.codepen.io/89905/coverflow--MOM-Remixes-1024x1024.jpg" width="1200" height="1200" />
    </li>
    <li id="card_5">
        <img src="https://assets.codepen.io/89905/coverflow--ALONE-TOGETHER-remix-V71-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_6">
        <img src="https://assets.codepen.io/89905/coverflow--Nature-Therapy-Pre-LR-550x550.png" width="1200" height="1200" />
    </li>
    <li id="card_7">
        <img src="https://assets.codepen.io/89905/coverflow--Deep-Dive-Ambient-Edits-V8-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_8">
        <img src="https://assets.codepen.io/89905/coverflow--Alpine-Koresma-x-Aroth-Artwork-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_9">
        <img src="https://assets.codepen.io/89905/coverflow--Out-Of-the-Dark-Cover-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_11">
        <img 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 src="https://assets.codepen.io/89905/coverflow--Deep-Dive-EP-Cover-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_13">
        <img src="https://assets.codepen.io/89905/coverflow--Blackrose-Cover-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_14">
        <img src="https://assets.codepen.io/89905/coverflow--FW-Imagine-Gold-Remixes2-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_15">
        <img src="https://assets.codepen.io/89905/coverflow--We-Are-COVER-MAIN-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_16">
        <img src="https://assets.codepen.io/89905/coverflow--Bath-House-Flat-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_17">
        <img src="https://assets.codepen.io/89905/coverflow--Pronoia-JPG-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_18">
        <img 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 src="https://assets.codepen.io/89905/coverflow--EMANCIPATOR_MOM_AlbumCover-2000px-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_20">
        <img src="https://assets.codepen.io/89905/coverflow--MURGE-ep-cvr-3000x3000-550x550.jpg" width="1200" height="1200" />
    </li>
    <li id="card_21">
        <img 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 src="https://assets.codepen.io/89905/coverflow--cover-550x550.jpg" width="1200" height="1200" />
    </li>
</ul>

<div class="warning warning--info">
	<p>ℹ️ Your browser does not support CSS Scroll-Linked Animations with <code>@scroll-timeline</code>. To cater for this, <a href="https://github.com/flackr/scroll-timeline">a polyfill</a> has been loaded. Alternatively you can check out <a href="https://codepen.io/bramus/pen/PobZbBV" target="_top">a WAAPI-based ScrollTimeline version</a> or <a href="https://twitter.com/bramus/status/1357391991114502144" target="_top" rel="noopener noreferrer">a recording of this demo</a>.</p>
</div>
              
            
!

CSS

              
                /*

  🤩 Pure CSS Coverflow Implementation, thanks to CSS @scroll-timeline.

  👨‍🔬 Experimental technology
      
     🤖 Chromium 89+ with the flag “Experimental Web Platform Features” enabled
     🦊 Firefox 97 with `layout.css.scroll-linked-animations.enabled` set to `true`

     🩹 Browsers that don’t support @scroll-timeline, are polyfilled with https://github.com/flackr/scroll-timeline/

  ℹ️ For a full explanation on CSS @scroll-timeline check:

    🔗 https://brm.us/scroll-linked-animations-pt1 — Scroll-Linked Animations + Scroll-Timeline Introduction
    🔗 https://brm.us/scroll-linked-animations-pt2 — Scroll-Linked Animations with Element-Based Offsets
  
  👋 Follow me here on CodePen or on https://twitter.com/bramus to get more demos

  🤓 I didn't manually create all the @scroll-timelines but, instead, had a little helper script generate 'm for me
   
     🔗 https://gist.github.com/bramus/3a3759d2bd63ff7e70cf8036349f45d2

*/

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

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

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

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

	display: flex;
	place-items: center;
}

.cards {
	list-style: none;
	overflow: 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);
}

.warning a {
	color: blue;
}

.warning--info {
	border: 1px solid #123456;
	background: rgba(205 230 255 / 0.8);
}

@supports (animation-timeline: works) {
	.warning {
		display: none;
	}
}

/* Our animations */
@keyframes adjust-z-index {
	0% {
		z-index: 1;
	}
	35% {
		z-index: 100;
	}
	50% {
		z-index: 10000;
	}
	65% {
		z-index: 100;
	}
	100% {
		z-index: 1;
	}
}

@keyframes rotate-cover {
	0% {
		transform: translateX(-100%) rotateY(-45deg);
	}
	35% {
		transform: translateX(0) rotateY(-45deg);
	}
	50% {
		transform: rotateY(0deg) translateZ(1em) scale(1.5);
	}
	65% {
		transform: translateX(0) rotateY(45deg);
	}
	100% {
		transform: translateX(100%) rotateY(45deg);
	}
}

.cards li {
	perspective: 40em;

	animation: 1s linear adjust-z-index both;
	animation-timeline: faux-animation-timeline;
	/* Prevent FOUC */
	position: relative;
	z-index: 1;

	will-change: z-index;
}

.cards li > img {
	animation: 1s linear rotate-cover both;
	animation-timeline: faux-animation-timeline;
	/* Prevent FOUC */
	transform: translateX(-150%) rotateY(-45deg);

	will-change: transform;
}

@scroll-timeline scroll-in-cards-card_0 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_0) end 0;
	end: selector(#card_0) start 0;
	scroll-offsets: selector(#card_0) end 0, selector(#card_0) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_0 {
	animation-timeline: scroll-in-cards-card_0;
}

/* Adjust the album cover on scroll (perspective) */
#card_0 > img {
	animation-timeline: scroll-in-cards-card_0;
}

@scroll-timeline scroll-in-cards-card_1 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_1) end 0;
	end: selector(#card_1) start 0;
	scroll-offsets: selector(#card_1) end 0, selector(#card_1) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_1 {
	animation-timeline: scroll-in-cards-card_1;
}

/* Adjust the album cover on scroll (perspective) */
#card_1 > img {
	animation-timeline: scroll-in-cards-card_1;
}

@scroll-timeline scroll-in-cards-card_2 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_2) end 0;
	end: selector(#card_2) start 0;
	scroll-offsets: selector(#card_2) end 0, selector(#card_2) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_2 {
	animation-timeline: scroll-in-cards-card_2;
}

/* Adjust the album cover on scroll (perspective) */
#card_2 > img {
	animation-timeline: scroll-in-cards-card_2;
}

@scroll-timeline scroll-in-cards-card_3 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_3) end 0;
	end: selector(#card_3) start 0;
	scroll-offsets: selector(#card_3) end 0, selector(#card_3) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_3 {
	animation-timeline: scroll-in-cards-card_3;
}

/* Adjust the album cover on scroll (perspective) */
#card_3 > img {
	animation-timeline: scroll-in-cards-card_3;
}

@scroll-timeline scroll-in-cards-card_4 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_4) end 0;
	end: selector(#card_4) start 0;
	scroll-offsets: selector(#card_4) end 0, selector(#card_4) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_4 {
	animation-timeline: scroll-in-cards-card_4;
}

/* Adjust the album cover on scroll (perspective) */
#card_4 > img {
	animation-timeline: scroll-in-cards-card_4;
}

@scroll-timeline scroll-in-cards-card_5 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_5) end 0;
	end: selector(#card_5) start 0;
	scroll-offsets: selector(#card_5) end 0, selector(#card_5) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_5 {
	animation-timeline: scroll-in-cards-card_5;
}

/* Adjust the album cover on scroll (perspective) */
#card_5 > img {
	animation-timeline: scroll-in-cards-card_5;
}

@scroll-timeline scroll-in-cards-card_6 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_6) end 0;
	end: selector(#card_6) start 0;
	scroll-offsets: selector(#card_6) end 0, selector(#card_6) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_6 {
	animation-timeline: scroll-in-cards-card_6;
}

/* Adjust the album cover on scroll (perspective) */
#card_6 > img {
	animation-timeline: scroll-in-cards-card_6;
}

@scroll-timeline scroll-in-cards-card_7 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_7) end 0;
	end: selector(#card_7) start 0;
	scroll-offsets: selector(#card_7) end 0, selector(#card_7) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_7 {
	animation-timeline: scroll-in-cards-card_7;
}

/* Adjust the album cover on scroll (perspective) */
#card_7 > img {
	animation-timeline: scroll-in-cards-card_7;
}

@scroll-timeline scroll-in-cards-card_8 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_8) end 0;
	end: selector(#card_8) start 0;
	scroll-offsets: selector(#card_8) end 0, selector(#card_8) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_8 {
	animation-timeline: scroll-in-cards-card_8;
}

/* Adjust the album cover on scroll (perspective) */
#card_8 > img {
	animation-timeline: scroll-in-cards-card_8;
}

@scroll-timeline scroll-in-cards-card_9 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_9) end 0;
	end: selector(#card_9) start 0;
	scroll-offsets: selector(#card_9) end 0, selector(#card_9) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_9 {
	animation-timeline: scroll-in-cards-card_9;
}

/* Adjust the album cover on scroll (perspective) */
#card_9 > img {
	animation-timeline: scroll-in-cards-card_9;
}

@scroll-timeline scroll-in-cards-card_11 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_11) end 0;
	end: selector(#card_11) start 0;
	scroll-offsets: selector(#card_11) end 0, selector(#card_11) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_11 {
	animation-timeline: scroll-in-cards-card_11;
}

/* Adjust the album cover on scroll (perspective) */
#card_11 > img {
	animation-timeline: scroll-in-cards-card_11;
}

@scroll-timeline scroll-in-cards-card_12 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_12) end 0;
	end: selector(#card_12) start 0;
	scroll-offsets: selector(#card_12) end 0, selector(#card_12) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_12 {
	animation-timeline: scroll-in-cards-card_12;
}

/* Adjust the album cover on scroll (perspective) */
#card_12 > img {
	animation-timeline: scroll-in-cards-card_12;
}

@scroll-timeline scroll-in-cards-card_13 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_13) end 0;
	end: selector(#card_13) start 0;
	scroll-offsets: selector(#card_13) end 0, selector(#card_13) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_13 {
	animation-timeline: scroll-in-cards-card_13;
}

/* Adjust the album cover on scroll (perspective) */
#card_13 > img {
	animation-timeline: scroll-in-cards-card_13;
}

@scroll-timeline scroll-in-cards-card_14 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_14) end 0;
	end: selector(#card_14) start 0;
	scroll-offsets: selector(#card_14) end 0, selector(#card_14) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_14 {
	animation-timeline: scroll-in-cards-card_14;
}

/* Adjust the album cover on scroll (perspective) */
#card_14 > img {
	animation-timeline: scroll-in-cards-card_14;
}

@scroll-timeline scroll-in-cards-card_15 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_15) end 0;
	end: selector(#card_15) start 0;
	scroll-offsets: selector(#card_15) end 0, selector(#card_15) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_15 {
	animation-timeline: scroll-in-cards-card_15;
}

/* Adjust the album cover on scroll (perspective) */
#card_15 > img {
	animation-timeline: scroll-in-cards-card_15;
}

@scroll-timeline scroll-in-cards-card_16 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_16) end 0;
	end: selector(#card_16) start 0;
	scroll-offsets: selector(#card_16) end 0, selector(#card_16) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_16 {
	animation-timeline: scroll-in-cards-card_16;
}

/* Adjust the album cover on scroll (perspective) */
#card_16 > img {
	animation-timeline: scroll-in-cards-card_16;
}

@scroll-timeline scroll-in-cards-card_17 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_17) end 0;
	end: selector(#card_17) start 0;
	scroll-offsets: selector(#card_17) end 0, selector(#card_17) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_17 {
	animation-timeline: scroll-in-cards-card_17;
}

/* Adjust the album cover on scroll (perspective) */
#card_17 > img {
	animation-timeline: scroll-in-cards-card_17;
}

@scroll-timeline scroll-in-cards-card_18 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_18) end 0;
	end: selector(#card_18) start 0;
	scroll-offsets: selector(#card_18) end 0, selector(#card_18) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_18 {
	animation-timeline: scroll-in-cards-card_18;
}

/* Adjust the album cover on scroll (perspective) */
#card_18 > img {
	animation-timeline: scroll-in-cards-card_18;
}

@scroll-timeline scroll-in-cards-card_19 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_19) end 0;
	end: selector(#card_19) start 0;
	scroll-offsets: selector(#card_19) end 0, selector(#card_19) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_19 {
	animation-timeline: scroll-in-cards-card_19;
}

/* Adjust the album cover on scroll (perspective) */
#card_19 > img {
	animation-timeline: scroll-in-cards-card_19;
}

@scroll-timeline scroll-in-cards-card_20 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_20) end 0;
	end: selector(#card_20) start 0;
	scroll-offsets: selector(#card_20) end 0, selector(#card_20) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_20 {
	animation-timeline: scroll-in-cards-card_20;
}

/* Adjust the album cover on scroll (perspective) */
#card_20 > img {
	animation-timeline: scroll-in-cards-card_20;
}

@scroll-timeline scroll-in-cards-card_21 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_21) end 0;
	end: selector(#card_21) start 0;
	scroll-offsets: selector(#card_21) end 0, selector(#card_21) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_21 {
	animation-timeline: scroll-in-cards-card_21;
}

/* Adjust the album cover on scroll (perspective) */
#card_21 > img {
	animation-timeline: scroll-in-cards-card_21;
}

@scroll-timeline scroll-in-cards-card_22 {
	source: selector(#cards);
	orientation: inline;
	start: selector(#card_22) end 0;
	end: selector(#card_22) start 0;
	scroll-offsets: selector(#card_22) end 0, selector(#card_22) start 0;
}

/* Adjust the li on scroll (z-index) */
#card_22 {
	animation-timeline: scroll-in-cards-card_22;
}

/* Adjust the album cover on scroll (perspective) */
#card_22 > img {
	animation-timeline: scroll-in-cards-card_22;
}

#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

              
                
              
            
!
999px

Console