Infinite horizontal slider

Developer
Size
2,009 Kb
Views
32,384

How do I make an infinite horizontal slider?

What is a infinite horizontal slider? How do you make a infinite horizontal slider? This script and codes were developed by Eddy on 27 August 2022, Saturday.

Infinite horizontal slider Previews

Infinite horizontal slider - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Infinite horizontal slider</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="carousel"> <div class="carousel-inner"> <div id="a" class="item">a</div> <div id="b" class="item">b</div> <div id="c" class="item">c</div> <div id="d" class="item">d</div> <div id="e" class="item">e</div> <div id="f" class="item">f</div> <div id="g" class="item">g</div> <div id="h" class="item">h</div> <div id="i" class="item">i</div> </div>
</div> <script src="js/index.js"></script>
</body>
</html>

Infinite horizontal slider - Script Codes CSS Codes

 .carousel { position: relative; width: 600px; height: 150px; margin: 0 auto; overflow: hidden; } .carousel-inner { position: absolute; /*width: 600px;*/ height: 150px; } .item { width: 150px; height: 150px; padding-top: 35px; float: left; text-align: center; font-size: 60px; }

Infinite horizontal slider - Script Codes JS Codes

var firstval = 0;
var pageSize = 600;
var page = 0;
function runCarousel(carousel, elementcount, elementPerPage, timer) { if(page >= Math.round(elementcount/elementPerPage)) { page = 0; firstval = 0; parent.style.left = 0; } firstval += 5; parent = carousel.querySelector('.carousel-inner'); parent.style.left = "-" + firstval + "px"; if (!(firstval % pageSize)) { setTimeout(function() {runCarousel(carousel, elementcount, elementPerPage, timer)}, timer); page += 1; return; } setTimeout(function() {runCarousel(carousel, elementcount, elementPerPage, timer)}, 20);
} var elementcount = document.querySelector('.carousel').querySelector('.carousel-inner').querySelectorAll('.item').length;
runCarousel(document.querySelector('.carousel'), elementcount, 4, 3000);
Infinite horizontal slider - Script Codes
Infinite horizontal slider - Script Codes
Home Page Home
Developer Eddy
Username emnbdx
Uploaded August 27, 2022
Rating 3
Size 2,009 Kb
Views 32,384
Do you need developer help for Infinite horizontal slider?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Eddy (emnbdx) Script Codes
Create amazing sales emails with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!