Responsive Product Slider — Html Css Codepen

/* responsive adjustments */ @media (max-width: 768px) .slider-container padding: 1.5rem 0.5rem 2rem 0.5rem; .section-head h2 font-size: 1.7rem; .product-title font-size: 0.95rem; .current-price font-size: 1.25rem; .swiper-button-next, .swiper-button-prev width: 36px; height: 36px; .swiper-button-next:after, .swiper-button-prev:after font-size: 1rem;

.swiper-button-next:after, .swiper-button-prev:after font-size: 1.2rem; font-weight: bold; color: #2c4e6e;

/* image wrapper with aspect ratio */ .product-img position: relative; background: #f4f8fe; padding: 1rem; display: flex; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid #edf2f7; Responsive Product Slider Html Css Codepen

.swiper-slide height: auto; display: flex; transition: transform 0.2s ease;

<!-- Product 7 --> <div class="swiper-slide"> <div class="product-card"> <div class="product-img"> <img src="https://cdn-icons-png.flaticon.com/512/4343/4343920.png" alt="Sunglasses" loading="lazy"> </div> <div class="product-info"> <div class="product-category">Fashion</div> <div class="product-title">Aero Polarized</div> <div class="product-desc">UV400 protection, lightweight TR90 frame</div> <div class="price-row"> <span class="current-price">$45</span> <span class="old-price">$65</span> </div> <button class="btn-add" aria-label="Add to cart">+ Add to Cart</button> </div> </div> </div> /* responsive adjustments */ @media (max-width: 768px)

/* badge / discount */ .badge position: absolute; top: 16px; left: 16px; background: #e73c3c; color: white; font-size: 0.7rem; font-weight: 700; padding: 0.25rem 0.7rem; border-radius: 40px; letter-spacing: 0.3px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); backdrop-filter: blur(2px); z-index: 2;

.product-img img width: 100%; max-width: 220px; height: auto; aspect-ratio: 1 / 0.95; object-fit: contain; transition: transform 0.4s ease; display: block; margin: 0 auto; .section-head h2 font-size: 1.7rem

.swiper-pagination-bullet background: #bdd4e6; opacity: 0.6; width: 8px; height: 8px;

/* section header */ .section-head text-align: center; margin-bottom: 2rem;

/* main container */ .slider-container max-width: 1400px; width: 100%; margin: 0 auto; background: rgba(255,255,255,0.4); backdrop-filter: blur(0px); border-radius: 2.5rem; padding: 2rem 1rem 2.5rem 1rem; box-shadow: 0 20px 35px -12px rgba(0,0,0,0.08);

// Add to cart button interactive feedback (simple alert simulation for demo) const addBtns = document.querySelectorAll('.btn-add'); addBtns.forEach(btn => btn.addEventListener('click', (e) => e.preventDefault(); e.stopPropagation(); const productCard = btn.closest('.product-card'); const productName = productCard?.querySelector('.product-title')?.innerText ); ); ); </script> </body> </html>

Arrow Left Arrow Right
Slideshow Left Arrow Slideshow Right Arrow