CSS 3D Card

Date: 2024-11-11
* { box-sizing: border-box; }
body { font-family: sans-serif; }

:root {
  --card-rotate: 10deg;
}

.scene {
  width: 200px;
  height: 200px;
  perspective: 400px;
}

.card {
  width: 200px;
  height: 200px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s;
  transform: translateZ(-1px) rotateY(var(--card-rotate));
}

.card.show-front  { --card-rotate: 0deg; }
.card.show-back   { --card-rotate: 180deg; }

.card-face {
  position: absolute;
  width: 200px;
  height: 200px;
  border: 2px solid black;
  line-height: 200px;
  font-size: 40px;
  font-weight: bold;
  color: black;
  text-align: center;
  border-radius:10px;
  background-color: #abcdef
}
.card-front  { transform: rotateY(  0deg) translateZ(1px); }
.card-back   { transform: rotateY(180deg) translateZ(1px); }
<div class="scene">
  <div class="card">
    <div class="card-face card-front">front</div>
    <div class="card-face card-back">back</div>
  </div>
</div>
90180cookie-checkCSS 3D Card