JSFiddle - React, Tailwind, and code Playground

by dzonit

HTML

```html
<!DOCTYPE html>
<html>
<head>
  <title>Stacked Cards with Varying Widths and Flip Animation</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f0f0f0;
    }

    #card-container {
      position: relative;
      width: 300px;
      height: 200px;
      margin: 50px auto;
      perspective: 1000px;
    }

    .card {
      position: absolute;
      top: 50%;
      left: 50%;
      height: 100%;
      background-color: #fff;
      border: 1px solid #000;
      border-radius: 15px;
      box-sizing: border-box;
      padding: 20px;
      box-shadow: 0 4px 6px rgba(0,0,0,0.1);
      color: #000;
      transform-style: preserve-3d;
      backface-visibility: hidden;
      transform-origin: center center;
      transition: transform 0.6s, z-index 0s 0.6s;
    }

    .card.flip {
      transform: rotateY(180deg);
    }

    #button-container {
      text-align: center;
      margin-top: 30px;
    }

    button {
      background-color: #333;
      color: #fff;
      border: none;
      padding: 10px 15px;
      margin: 5px;
      border-radius: 5px;
      cursor: pointer;
      transition: background-color 0.3s;
      font-size: 16px;
    }

    button:hover {
      background-color: #555;
    }
  </style>
</head>
<body>
  <div id="card-container">
    <div class="card" id="card1">Card 1 Content</div>
    <div class="card" id="card2">Card 2 Content</div>
    <div class="card" id="card3">Card 3 Content</div>
    <div class="card" id="card4">Card 4 Content</div>
    <div class="card" id="card5">Card 5 Content</div>
  </div>
  <div id="button-container">
    <button onclick="showCard(1)">Card 1</button>
    <button onclick="showCard(2)">Card 2</button>
    <button onclick="showCard(3)">Card 3</button>
    <button onclick="showCard(4)">Card 4</button>
    <button onclick="showCard(5)">Card 5</button>
  </div>
  <script>
    var cards = [
      { id: 'card1', element: document.getElementById('card1') },
      { id: 'card2',...