- const cards = [
- {title:"Duis bibendum", body:["Lectus sed iaculis eleifend, nisi nisi facilisis nunc", "A sagittis odio quam sed felis"]},
- {title:"Nam sagittis", body:["Fusce turpis ligula, placerat ut ultrices vel", "Phasellus sed erat vel sem mollis rutrum"]},
- {title:"Pellentesque sed", body:["Sed sit amet elit massa. Fusce molestie eleifend velit, a mollis ex dapibus ut. Integer lectus purus, tristique in dapibus sit amet, sagittis luctus erat"]},
- {title:"Nullam", body:["Donec pellentesque velit magna, nec volutpat sapien aliquam vitae","Proin sed est a turpis porttitor finibus"]},
- ]
.card_stack
each card in cards
.card_container
each className in ['card', 'card ghost']
div(class=className)
h2 #{card.title}
each paragraph in card.body
p #{paragraph}
View Compiled
body
display grid
place-items center
min-height 100vh
font-family 'Inter', sans-serif
background #242424
h2, p
margin 0
font inherit
h2
font-size 1.25rem
font-weight 500
.card_stack
--card-shown-x 5rem
--card-shown-y 3rem
--card-size-x 12rem
--card-size-y 8rem
--card-padding 1rem
display flex
flex-direction column
padding-right calc(var(--card-size-x) - var(--card-shown-x) + 2*var(--card-padding))
padding-bottom calc(var(--card-size-y) - var(--card-shown-y) + 2*var(--card-padding))
.card_container
position relative
margin-left calc((var(--num) - 1) * var(--card-shown-x))
width var(--card-shown-x)
height var(--card-shown-y)
for num in (1..5)
&:nth-child({num})
--num num
.card
position absolute
display flex
flex-direction column
gap .5rem
min-width var(--card-size-x)
min-height var(--card-size-y)
padding var(--card-padding)
border-radius 1rem
background #2C2C2C
color white
box-shadow 0 0 1.5rem -.25rem rgba(0,0,0,0.75)
&.ghost
z-index 1
opacity 0
transition .25s ease
&:not(:hover) .ghost
pointer-events none
&:hover .ghost
opacity 1
View Compiled
//Made for MrBanditHat after they asked how to do this
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.