
A professional Banner Slider section is one of the most important parts of an eCommerce website because it creates the first impression for visitors and highlights important products, offers, and brand messages. A modern and attractive slider helps capture customer attention instantly and encourages users to explore more products on your online store. With eye-catching visuals, smooth animations, and clear call-to-action buttons, a well-designed banner slider can improve engagement and increase sales conversions.
<style>
.bg-overlay{
z-index: 0;
}
.bg-overlay::before {
z-index: -1; /* or 0 depending on layering need */
}
.bg-overlay::before{
content: "";
transition: background 0.3s, border-radius 0.3s, opacity 0.3s;
box-sizing: border-box;
background: radial-gradient(48.85% 106.13% at 64.03% 55.55%, rgba(36, 20, 5, 0) 0%, #241405 78.44%, rgba(36, 20, 5, 0.960021) 100%) !important;
}
/* Pagination Container */
.hero-slider-cursole-pagination {
display: flex;
justify-content: center;
align-items: center;
gap: 18px;
}
/* Navigation Buttons */
.hero-nav-btn {
cursor: pointer;
transition: all 0.3s ease;
}
.hero-nav-btn .elementor-icon{
margin-bottom: -7px;
}
.hero-nav-btn:hover .elementor-icon svg path{
stroke: white;
}
/* Pagination */
.pagination-number {
display: flex;
gap: 18px;
align-items: center;
}
.page-number {
color: rgba(255, 255, 255, 0.4);
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
padding: 0;
background-color: transparent;
border: none;
background: transparent;
font-weight: 400!important;
}
.page-number.active {
color: white;
}
.page-number:hover {
color: white;
background-color: transparent;
}
.slider-wrapper {
position: relative;
}
.slider-track {
transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.slide {
min-width: 100%;
height: 100%;
}
.video-play .elementor-custom-embed-image-overlay{
width: 224px;
height: 164px;
}
@media(max-width: 767px){
.video-play .elementor-custom-embed-image-overlay{
width: 100%;
height: 100%;
}
}
.video-play .elementor-custom-embed-image-overlay::before{
position: absolute;
width: 100%;
height: 100%;
left: 0;
content: "";
transition: background 0.3s, border-radius 0.3s, opacity 0.3s;
box-sizing: border-box;
background: #241404!important;
z-index: 9;
opacity: 0.5;
border-radius: 8px;
}
.video-play img{
height: 100%;
width: 100%!important;
border-radius: 8px;
}
.video-play .elementor-custom-embed-play{
line-height: 0;
z-index: 99;
background: white;
padding: 7px 7px;
border-radius: 100px;
border: 2px solid #ffffff33;
}
.video-play:hover .elementor-custom-embed-play{
background-color: #D25903;
}
.video-play:hover .elementor-custom-embed-play svg{
fill: white!important;
}
</style>slider-container bg-overlay hero-nav-btn active slider-wrapper slider-track slide video-play
sliderTrack prevBtn nextBtn
<script> document.addEventListener
("DOMContentLoaded", function
() { const sliderContainer = document.querySelector(".slider-container"); const sliderTrack = document.querySelector(".slider-track"); // Select the original slide items only const originalSlides = Array.from(document.querySelector
All(".slide")); const totalSlides = originalSlides.length; let currentIndex = 0; // Index relative to the original slides (0 to totalSlides - 1) let trackPosition = 1; // Index relative to the track including clones (1 to totalSlides) let autoSlideInterval; const autoSlideDelay = 4000; // 4 seconds const transitionDuration = 500; // Must match CSS transition duration // Use querySelector for elements that don't change names const prevBtn = document.getElementById('prevBtn'); const nextBtn = document.getElementById('nextBtn'); const pagination = document.getElementById
('paginationNumber'); /* --- 1. Initialization: Cloning for Infinite Loop --- */ function initSlider() { // Clear existing clones if any (important for refactoring) const currentItems = Array.from(sliderTrack.children); currentItems.slice(totalSlides).
forEach(item => item.remove()); currentItems.slice(0, currentItems.length - totalSlides).forEach(item => item.remove()); // Clone last slide and add at beginning (for smooth transition from 1 to 5) const lastClone = originalSlides[totalSlides - 1].cloneNode(true); sliderTrack.insertBefore(lastClone, sliderTrack.firstChild); // Clone first slide and add at end (for smooth transition from 5 to 1) const firstClone = originalSlides[0].cloneNode(true); sliderTrack.appendChild(firstClone); // Set initial position: Skip the first clone and show the first real slide sliderTrack.style.transition = 'none'; sliderTrack.style.transform = 'translateX(-100%)'; trackPosition = 1; // Start at the first real slide } /* --- 2. Pagination --- */ function createPagination() { if (!pagination) return; pagination.innerHTML = ''; for (let i = 0; i < totalSlides; i++) { const pageNum = document.createElement('div'); pageNum.className = 'page-number'; pageNum.textContent = (i + 1).toString().padStart(2, '0'); // Use the original slide index (i) for navigation pageNum.addEventListener('click', () => goToSlide(i)); pagination.appendChild(pageNum); } updatePagination(); } function updatePagination() { if (!pagination) return; const pageNumbers = pagination.querySelectorAll('.page-number'); pageNumbers.forEach((num, index) => { num.classList.toggle('active', index === currentIndex); }); } /* --- 3. Slider Movement Core Function --- */ function updateSlider(isNavigating = true) { // Calculate the percentage transform based on the trackPosition (which includes clones) const translateX = -(trackPosition * 100); sliderTrack.style.transform = `translateX(${translateX}%)`; // Apply smooth transition before movement if (isNavigating) { sliderTrack.style.transition = `transform ${transitionDuration / 1000}s cubic-bezier(0.25, 0.46, 0.45, 0.94)`; } // Seamless looping reset logic if (trackPosition === totalSlides + 1) { // We've moved to the cloned first slide (after the real last slide) setTimeout(() => { // Instantly snap back to the position of the first real slide sliderTrack.style.transition = 'none'; trackPosition = 1; // Reset to first real slide's track index sliderTrack.style.transform = 'translateX(-100%)'; }, transitionDuration); currentIndex = 0; // Reset original slide index } else if (trackPosition === 0) { // We've moved to the cloned last slide (before the real first slide) setTimeout(() => { // Instantly snap back to the position of the last real slide sliderTrack.style.transition = 'none'; trackPosition = totalSlides; // Reset to last real slide's track index sliderTrack.style.transform = `translateX(-${totalSlides * 100}%)`; }, transitionDuration); currentIndex = totalSlides - 1; // Reset original slide index } else { // Update the original slide index based on the track position currentIndex = trackPosition - 1; } updatePagination(); } /* --- 4. Navigation Handlers --- */ function nextSlide() { trackPosition++; updateSlider(); resetAutoSlide(); } function prevSlide() { trackPosition--; updateSlider(); resetAutoSlide(); } function goToSlide(index) { // The track position is the index + 1, because index 0 is the last clone trackPosition = index + 1; updateSlider(); resetAutoSlide(); } /* --- 5. Auto Slide & Interaction --- */ function startAutoSlide() { stopAutoSlide(); autoSlideInterval = setInterval(() => { nextSlide(); }, autoSlideDelay); } function stopAutoSlide() { clearInterval(autoSlideInterval); } function resetAutoSlide() { stopAutoSlide(); startAutoSlide(); } // Event listeners if (nextBtn) nextBtn.addEventListener("click", nextSlide); if (prevBtn) prevBtn.addEventListener("click", prevSlide); sliderContainer.addEventListener
('mouseenter', stopAutoSlide); sliderContainer.addEventListener
('mouseleave', startAutoSlide); /* --- 6. Final Setup --- */ initSlider(); createPagination(); startAutoSlide(); // The track position must be 1 for the first update, setting currentIndex to 0 currentIndex = 0; updatePagination(); }); </script>
<div class="pagination-number" id="paginationNumber">Pagination Number</div>
Every project is crafted with performance, responsiveness, and search engine optimization in mind to help your business stand out online.
Copyright 2026 @ Muhammad Abu Bakkar | All Rights Reserved