Circular Carousel - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Circular Carousel</title> <style> body { font-family: 'Arial', sans-serif; background: #fff; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .carousel-container { position: relative; width: 400px; height: 400px; overflow: hidden; border-radius: 50%; box-shadow: 0 10px 20px rgba(0,0,0,0.2); } .carousel-slide { display: flex; position: absolute; width: 100%; height: 100%; transition: transform 0.5s ease-in-out; transform-origin: center center; } .carousel-item { min-width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; font-size: 2rem; color: white; position: absolute; top: 0; left: 0; } .carousel-item:nth-child(1) { background: linear-gradient(135deg, #6a11cb, #2575fc); } .carousel-item:nth-child(2) { background: linear-gradient(135deg, #ff7e5f, #feb47b); } .carousel-item:nth-child(3) { background: linear-gradient(135deg, #43cea2, #185a9d); } .carousel-item:nth-child(4) { background: linear-gradient(135deg, #ff9966, #ff5e62); } .carousel-icons { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; } .carousel-icon { width: 15px; height: 15px; margin: 0 5px; background: white; border-radius: 50%; cursor: pointer; transition: background 0.3s; } .carousel-icon.active { background: #333; } .carousel-controls { position: absolute; top: 50%; width: 100%; display: flex; justify-content: space-between; transform: translateY(-50%); } .carousel-control { background: rgba(0,0,0,0.5); border: none; color: white; padding: 10px; cursor: pointer; font-size: 1.5rem; transition: background 0.3s; } .carousel-control:hover { background: rgba(0,0,0,0.8); } .transform1{transform: rotate(0deg) translateX(200px) rotate(0deg);} .transform2{transform: rotate(90deg) translateX(200px) rotate(-90deg);} .transform3{transform: rotate(180deg) translateX(200px) rotate(-180deg);} .transform4{transform: rotate(270deg) translateX(200px) rotate(-270deg);} </style> </head> <body> <div class="carousel-container"> <div class="carousel-slide"> <div class="carousel-item" style="transform: rotate(0deg) translateX(200px) rotate(0deg);"> 1 </div> <div class="carousel-item" style="transform: rotate(90deg) translateX(200px) rotate(-90deg);"> 2 </div> <div class="carousel-item" style="transform: rotate(180deg) translateX(200px) rotate(-180deg);"> 3 </div> <div class="carousel-item" style="transform: rotate(270deg) translateX(200px) rotate(-270deg);"> 4 </div> </div> <div class="carousel-icons"> <div class="carousel-icon active"></div> <div class="carousel-icon"></div> <div class="carousel-icon"></div> <div class="carousel-icon"></div> </div> <div class="carousel-controls"> <button type="button" class="carousel-control" id="prevBtn">❮</button> <button type="button" class="carousel-control" id="nextBtn">❯</button> </div> </div> <script> const slide = document.querySelector('.carousel-slide'); const items = document.querySelectorAll('.carousel-item'); const prevBtn = document.getElementById('prevBtn'); const nextBtn = document.getElementById('nextBtn'); const icons = document.querySelectorAll('.carousel-icon'); let counter = 0; const updateCarousel = () => { slide.style.transform = 'rotate(' + (-90 * counter) + 'deg)'; icons.forEach((icon, index) => { icon.classList.toggle('active', index === counter); }); }; nextBtn.addEventListener('click', () => { counter = (counter + 1) % items.length; updateCarousel(); }); prevBtn.addEventListener('click', () => { counter = (counter - 1 + items.length) % items.length; updateCarousel(); }); icons.forEach((icon, index) => { icon.addEventListener('click', () => { counter = index; updateCarousel(); }); }); updateCarousel(); </script> </body> </html>