Created
September 15, 2025 03:33
-
-
Save aditnanda/733134c7b4d92d15ce30f13660e3c764 to your computer and use it in GitHub Desktop.
Untuk Gallery Slider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Product Image Carousel (Main + Thumbnails)</title> | |
| <!-- Swiper CSS --> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" /> | |
| <style> | |
| :root { | |
| --radius: 14px; | |
| } | |
| body { | |
| margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; | |
| background: #0f172a; color: #e2e8f0; | |
| display: grid; place-items: center; min-height: 100vh; padding: 24px; | |
| } | |
| .wrap { width: min(1100px, 100%); } | |
| h1 { font-size: clamp(18px, 3vw, 28px); margin: 0 0 16px; font-weight: 700; letter-spacing: .3px; } | |
| .gallery { width: 100%; } | |
| .main { border-radius: var(--radius); overflow: hidden; } | |
| .main .swiper-slide { background: #0b1220; display: grid; place-items: center; } | |
| .main img { width: 100%; height: clamp(240px, 50vw, 520px); object-fit: cover; display: block; } | |
| .thumbs { margin-top: 12px; } | |
| .thumbs .swiper-slide { opacity: .5; cursor: pointer; border-radius: 10px; overflow: hidden; border: 1px solid rgba(148,163,184,.25); transition: opacity .2s ease; } | |
| .thumbs .swiper-slide-thumb-active { opacity: 1; border-color: rgba(148,163,184,.6); } | |
| .thumbs img { height: 80px; width: 100%; object-fit: cover; display: block; } | |
| /* Buttons & Pagination */ | |
| .swiper-button-prev, .swiper-button-next { color: #e2e8f0; } | |
| .swiper-pagination-bullet { background: #94a3b8; opacity: .6; } | |
| .swiper-pagination-bullet-active { background: #e2e8f0; opacity: 1; } | |
| .card { background: linear-gradient(180deg, rgba(148,163,184,.08), rgba(148,163,184,.03)); padding: 16px; border: 1px solid rgba(148,163,184,.12); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(2,6,23,.35) inset, 0 10px 30px rgba(2,6,23,.25); | |
| } | |
| .meta { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin-top: 14px; } | |
| .price { font-weight: 800; font-size: clamp(18px, 3vw, 24px); } | |
| .cta { background: #facc15; color: #111827; padding: 10px 14px; border-radius: 10px; border: none; font-weight: 700; cursor: pointer; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="wrap"> | |
| <div class="gallery card"> | |
| <!-- Main slider --> | |
| <div class="swiper main"> | |
| <div class="swiper-wrapper"> | |
| <!-- Replace srcs with your own images --> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1550355291-bbee04a92027?q=80&w=1600&auto=format&fit=crop" alt="car 1" /></div> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1503376780353-7e6692767b70?q=80&w=1600&auto=format&fit=crop" alt="car 2" /></div> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1552519507-da3b142c6e3d?q=80&w=1600&auto=format&fit=crop" alt="car 3" /></div> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1517336714731-489689fd1ca8?q=80&w=1600&auto=format&fit=crop" alt="car 4" /></div> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1518306727298-4c17e1bf6942?q=80&w=1600&auto=format&fit=crop" alt="car 5" /></div> | |
| </div> | |
| <div class="swiper-button-prev"></div> | |
| <div class="swiper-button-next"></div> | |
| <div class="swiper-pagination"></div> | |
| </div> | |
| <!-- Thumbnails slider --> | |
| <div class="swiper thumbs"> | |
| <div class="swiper-wrapper"> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1550355291-bbee04a92027?q=80&w=400&auto=format&fit=crop" alt="thumb 1" /></div> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1503376780353-7e6692767b70?q=80&w=400&auto=format&fit=crop" alt="thumb 2" /></div> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1552519507-da3b142c6e3d?q=80&w=400&auto=format&fit=crop" alt="thumb 3" /></div> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1517336714731-489689fd1ca8?q=80&w=400&auto=format&fit=crop" alt="thumb 4" /></div> | |
| <div class="swiper-slide"><img src="https://images.unsplash.com/photo-1518306727298-4c17e1bf6942?q=80&w=400&auto=format&fit=crop" alt="thumb 5" /></div> | |
| </div> | |
| </div> | |
| <div class="meta"> | |
| <div class="price">Audi Q7 3.0 TFSI AT 2012</div> | |
| <button class="cta" onclick="alert('Chat penjual!')">Chat Penjual</button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Swiper JS --> | |
| <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script> | |
| <script> | |
| // Thumbnails | |
| const thumbs = new Swiper('.thumbs', { | |
| slidesPerView: 6, | |
| spaceBetween: 8, | |
| freeMode: true, | |
| watchSlidesProgress: true, | |
| breakpoints: { | |
| 0: { slidesPerView: 4 }, | |
| 640: { slidesPerView: 6 } | |
| } | |
| }); | |
| // Main gallery | |
| const main = new Swiper('.main', { | |
| loop: true, | |
| spaceBetween: 10, | |
| navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev' }, | |
| pagination: { el: '.swiper-pagination', clickable: true }, | |
| thumbs: { swiper: thumbs } | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment