Minimalist 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"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <title>Minimalist Carousel</title> <style> body { margin: 0; font-family: Arial, sans-serif; background: linear-gradient(to right, #00c6ff, #0072ff); overflow: hidden; background-attachment: fixed; } .carousel { position: relative; width: 100%; max-width: 100%; border-radius: 0; overflow: hidden; } .carousel .slides { display: flex; transition: transform 0.4s ease; } .carousel .slide { min-width: 100%; box-sizing: border-box; } .carousel .slide img { width: 100%; border-radius: 0; } .carousel .navigation { position: absolute; top: 50%; width: 100%; display: flex; justify-content: space-between; transform: translateY(-50%); } .carousel .nav-button { background: rgba(255, 255, 255, 0.2); border: none; padding: 10px; border-radius: 5px; cursor: pointer; color: #ffffff; transition: background 0.3s ease; } .carousel .nav-button:hover { background: rgba(255, 255, 255, 0.4); } .carousel .nav-prev { left: 10px; } .carousel .nav-next { right: 10px; } .carousel .nav-button i { font-size: 1.5rem; } @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css'); </style> </head> <body> <div class="carousel"> <div class="slides"> <div class="slide"> <img src="https://via.placeholder.com/1200x600/00c6ff/ffffff?text=Slide+1" alt="Slide 1"> </div> <div class="slide"> <img src="https://via.placeholder.com/1200x600/0072ff/ffffff?text=Slide+2" alt="Slide 2"> </div> <div class="slide"> <img src="https://via.placeholder.com/1200x600/00c6ff/ffffff?text=Slide+3" alt="Slide 3"> </div> </div> <div class="navigation"> <button class="nav-button nav-prev"><i class="fas fa-chevron-left"></i></button> <button class="nav-button nav-next"><i class="fas fa-chevron-right"></i></button> </div> </div> <script> const prevButton = document.querySelector('.nav-prev'); const nextButton = document.querySelector('.nav-next'); const slides = document.querySelector('.slides'); const slideCount = document.querySelectorAll('.slide').length; let index = 0; function showSlide(i) { if (i >= slideCount) index = 0; else if (i < 0) index = slideCount - 1; else index = i; slides.style.transform = `translateX(-${index * 100}%)`; } prevButton.addEventListener('click', () => showSlide(index - 1)); nextButton.addEventListener('click', () => showSlide(index + 1)); setInterval(() => showSlide(index + 1), 4000); </script> </body> </html>