<header><h1 tabindex="0" id="title">New Albums this week</h1></header>
<section class="cards">
<div class="cards__single">
<div class="cards__front">
<img
class="cards__image"
src="https://images.unsplash.com/photo-1514924527133-371124f6f5e3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=667&q=80"
alt="Bon Iver album"
/>
<h1 class="cards__artist" tabindex="0">Bon Iver</h1>
<p class="cards__album" tabindex="0">
<strong>For Emma, Forever Ago</strong>
</p>
</div>
<div class="cards__back">
<h2 tabindex="0">Songs</h2>
<ol>
<li>Flume</li>
<li>Lump Sum</li>
<li>Skinny Love</li>
<li>The Wolves</li>
<li>Blind Sided</li>
<li>Creature Fear</li>
<li>Team</li>
<li>For Emma</li>
<li>re:Stacks</li>
</ol>
<p class="cards__year">Year: 2008</p>
</div>
</div>
<div class="cards__single">
<div class="cards__front">
<img
class="cards__image"
src="https://images.unsplash.com/photo-1534254628711-b444d2945bcb?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=375&q=80"
alt="Guns N' Roses Album"
/>
<h1 class="cards__artist" tabindex="0">Guns N' Roses</h1>
<p class="cards__album" tabindex="0">
<strong>Apetite for Destruction</strong>
</p>
</div>
<div class="cards__back">
<h2 tabindex="0">Songs</h2>
<ol>
<li>Welcome to the Jungle</li>
<li>It'so Easy</li>
<li>Nightrain</li>
<li>Out Ta Get Me</li>
<li>Mr. Browstone</li>
<li>Paradise City</li>
<li>My Michelle</li>
<li>Think About You</li>
<li>Sweet Child of Mine</li>
<li>You're Crazy</li>
<li>Anything Goes</li>
<li>Rocket Queen</li>
</ol>
<p class="cards__year">Year: 1987</p>
</div>
</div>
<div class="cards__single">
<div class="cards__front">
<img
class="cards__image"
src="https://images.unsplash.com/photo-1542539097-00f1e264494f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80"
alt="Arctic Monkeys album"
/>
<h1 class="cards__artist" tabindex="0">Arctic Monkeys</h1>
<p class="cards__album" tabindex="0"><strong>Humbug</strong></p>
</div>
<div class="cards__back">
<h2 tabindex="0">Songs</h2>
<ol>
<li>My Propeller</li>
<li>Crying Lightning</li>
<li>Dangerous Animals</li>
<li>Secret Door</li>
<li>Potion Approaching</li>
<li>Fire and the Thud</li>
<li>Cornerstone</li>
<li>Dance Little Liar</li>
<li>Pretty Visitors</li>
<li>The Jeweller's Hands</li>
</ol>
<p class="cards__year">Year: 2009</p>
</div>
</div>
<div class="cards__single">
<div class="cards__front">
<img
class="cards__image"
src="https://images.unsplash.com/photo-1584679109597-c656b19974c9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80"
alt="Leon Bridges album"
/>
<h1 class="cards__artist" tabindex="0">Leon Bridges</h1>
<p class="cards__album" tabindex="0"><strong>Coming Home</strong></p>
</div>
<div class="cards__back">
<h2 tabindex="0">Songs</h2>
<ol>
<li>Coming Home</li>
<li>Better Man</li>
<li>Brown Skin Girl</li>
<li>Smooth Sailin</li>
<li>Shine</li>
<li>Lisa Sawyer</li>
<li>Flowers</li>
<li>Pull Away</li>
<li>Twistin' & Groovin</li>
<li>River</li>
</ol>
<p class="cards__year">Year: 2009</p>
</div>
</div>
</section>
body {
background: #eceee5;
}
#title {
color: #20263f;
font-family: "Dosis", sans-serif;
font-weight: 400;
font-size: 50px;
display: block;
text-align: center;
}
.cards {
display: flex;
flex-direction: column;
position: relative;
perspective: 1000px;
justify-content: center;
align-content: center;
align-items: center;
}
.cards__single {
background: #a64e43;
display: flex;
flex-direction: column;
margin-top: 20px;
width:80%;
border-radius: 16px;
box-shadow: 0 5px 18px rgba(0, 0, 0, 0.6);
cursor: pointer;
text-align: center;
-webkit-transition: transform 0.6s;
transform-style: preserve-3d;
transition: 0.5s;
-webkit-transition: 0.5s;
position: relative;
transition: transform 0.6s;
-webkit-transition: transform 0.6s;
}
.cards__image {
text-align: center;
width: 100%;
border-radius: 16px;
}
.cards__single.flip {
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
}
.cards__artist,
.cards__album {
color: #20263f;
}
.cards__front img {
margin: 0;
height: 250px;
}
.cards__album {
font-style: italic;
}
h2 {
margin: 0;
text-align: center;
}
li {
line-height: 21px;
}
.cards__front,
.cards__back {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
display: flex;
flex-direction: column;
}
.cards__front {
height: 100%;
transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
}
.cards__back {
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
position: absolute;
text-align: center;
right: 0;
left: 0;
top: 10px;
color: #20263f;
}
@media (min-width: 768px) {
.cards {
display: flex;
flex-direction: row;
justify-content: space-around;
align-content: center;
position: relative;
perspective: 1000px;
align-items: stretch;
}
.cards__single {
width: 20%;
}
}
const cards = document.querySelectorAll(".cards__single");
function flipCard() {
this.classList.toggle("flip");
}
cards.forEach((card) => card.addEventListener("click", flipCard));
//You can see full tutorial here
//https://www.ricardomoreira.io/blog/2020-06-15-flip-cards-with-javascript
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.