equipo.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!DOCTYPE html>
  2. <html lang="es">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Carrusel de Cards</title>
  7. <style>
  8. * {
  9. box-sizing: border-box;
  10. margin: 0;
  11. padding: 0;
  12. }
  13. body {
  14. display: flex;
  15. justify-content: center;
  16. align-items: center;
  17. height: 100vh;
  18. background-color: #f4f4f4;
  19. }
  20. .carousel-container {
  21. display: flex;
  22. flex-direction: column;
  23. align-items: center;
  24. position: relative;
  25. }
  26. .carousel {
  27. display: flex;
  28. transition: transform 0.4s ease-in-out;
  29. overflow: hidden;
  30. width: 300px;
  31. height: 200px;
  32. }
  33. .carousel-track {
  34. display: flex;
  35. transition: transform 0.4s ease-in-out;
  36. }
  37. .card {
  38. min-width: 100%;
  39. height: 100%;
  40. background-color: #fff;
  41. display: flex;
  42. justify-content: center;
  43. align-items: center;
  44. font-size: 24px;
  45. border: 1px solid #ddd;
  46. border-radius: 10px;
  47. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  48. }
  49. .carousel-controls {
  50. display: flex;
  51. justify-content: space-between;
  52. width: 120px;
  53. margin-top: 15px;
  54. }
  55. .carousel-btn {
  56. background-color: #333;
  57. color: #fff;
  58. border: none;
  59. padding: 10px;
  60. cursor: pointer;
  61. border-radius: 50%;
  62. }
  63. </style>
  64. </head>
  65. <body>
  66. <div class="carousel-container">
  67. <div class="carousel">
  68. <div class="carousel-track">
  69. <div class="card">Card 1</div>
  70. <div class="card">Card 2</div>
  71. <div class="card">Card 3</div>
  72. <div class="card">Card 4</div>
  73. <div class="card">Card 5</div>
  74. </div>
  75. </div>
  76. <!-- Contenedor de botones centrados -->
  77. <div class="carousel-controls">
  78. <button id="prevBtn" class="carousel-btn">⟨</button>
  79. <button id="nextBtn" class="carousel-btn">⟩</button>
  80. </div>
  81. </div>
  82. <script>
  83. const carouselTrack = document.querySelector('.carousel-track');
  84. const cards = document.querySelectorAll('.card');
  85. const prevBtn = document.getElementById('prevBtn');
  86. const nextBtn = document.getElementById('nextBtn');
  87. let currentIndex = 0;
  88. const totalCards = cards.length;
  89. function showCard(index) {
  90. carouselTrack.style.transform = `translateX(${-index * 100}%)`;
  91. }
  92. prevBtn.addEventListener('click', () => {
  93. currentIndex = (currentIndex > 0) ? currentIndex - 1 : totalCards - 1;
  94. showCard(currentIndex);
  95. });
  96. nextBtn.addEventListener('click', () => {
  97. currentIndex = (currentIndex < totalCards - 1) ? currentIndex + 1 : 0;
  98. showCard(currentIndex);
  99. });
  100. setInterval(() => {
  101. currentIndex = (currentIndex < totalCards - 1) ? currentIndex + 1 : 0;
  102. showCard(currentIndex);
  103. }, 3000);
  104. </script>
  105. </body>
  106. </html>