.cards
  each val in ['spade', 'heart', 'diamond', 'club']
    label(class=`card ${val}`, for=val)
      input(type="checkbox", id=val)
      .back
      .front
        .num-box.top.suit A
        .num-box.bottom.suit A
        .suit.main


View Compiled
@import url('https://fonts.googleapis.com/css2?family=Syne+Mono&display=swap');
* {
  box-sizing: border-box;
}
:root {
  --darkBg: #ffcc33;
  --lightBg: #fff3ce;
  --darkRed: #e22929;
  --lightRed: #ffd0d0;
  --darkBlack: #000;
  --lightBlack: #777;
}
// card layout
.cards {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin: 24px auto;
  perspective: 1000px; // 3d flip
}
.card {
  display: block;
  width: 150px;
  height: 200px;
  margin: 12px;
  position: relative;
  font-family: 'Syne Mono', monospace;
  cursor: pointer;
}
.front, .back {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 5px silver);
  border-radius: 12px;
  backface-visibility: hidden;
  transition: all 0.5s;
}
// back
.back {
  border: 6px solid #fff;
  background: conic-gradient(
    var(--darkBg) 25%, 
    var(--lightBg) 25%, 
    var(--lightBg) 50%, 
    var(--darkBg) 50%, 
    var(--darkBg) 75%, 
    var(--lightBg) 75%);
  background-size: 20px 20px;
  transform: rotateY(-180deg);
}
// front with suit
.front {
  background-color: #fff;
  font-size: 24px;
}
input[type=checkbox] {
  display: none;
  &:checked {
    ~ .front {
      transform: rotateY(180deg);
    }
    ~ .back {
      transform: rotateY(0deg);
    }
  }
}
// suits: black
.spade, .club {
  color: var(--darkBlack);
  .suit.main {
    background-image: linear-gradient(135deg, var(--darkBlack) 50%, var(--lightBlack) 50%);
  }
}
// suits: red
.heart, .diamond {
  color: var(--darkRed);
  .suit.main {
    background-image: linear-gradient(135deg, var(--darkRed) 50%, var(--lightRed) 50%);
  }
}
// suits unicode
.spade .suit:after {
  content: '\2660';
}
.heart .suit:after {
  content: '\2665';
}
.diamond .suit:after {
  content: '\2666';
}
.club .suit:after {
  content: '\2663';
}

// number
.num-box {
  text-align: center;
  position: absolute;
  width: 20px;
  &.top {
    top: 10px;
    left: 10px;
  }
  &.bottom {
    bottom: 10px;
    right: 10px;
    transform: rotate(180deg);
  }
  &.suit:after {
    display: block;
    font-size: 1.2em;
    margin-top: -10px;
  }
}
// main suit
.main {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 5em;
  color: transparent;
  -webkit-background-clip: text;
}


View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.