"Custom Horizontal Scroll Button JavaScript"
Bootstrap 4.1.1 Snippet by mdwaris198

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container mt-5"> <div class="bg-light p-3" id="content"> <p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p> </div> <div class="mt-4"> <button class="btn btn-danger" onclick="scrollLeft2()" >Prev</button> <button class="btn btn-danger" onclick="scrollRight()" >Next</button> </div> </div>
*{ box-sizing: border-box; margin: 0; padding: 0; } #content{ display: flex; width: 600px; overflow-x: scroll; scroll-behavior: smooth; } #content p{ padding: 30px; background: darkgreen; color:#fff; margin-right:15px; border-radius:10px; }
// scroll button function scrollLeft2(){ document.getElementById('content').scrollLeft -=300; } function scrollRight(){ document.getElementById('content').scrollLeft +=300; }

Related: See More


Questions / Comments: