How to design mobile touch slider using Swiper.js Plugin ? Last Updated : 29 Jul, 2024 Comments Improve Suggest changes Like Article Like Report In this article, we will learn how to design mobile touch sliders for mobile apps, mobile websites, or web apps using the JavaScript Swiper plugin. Approach:Download the required pre-compiled files from this link and save them in your working folder for the implementation of the following examples.Keep the downloaded files "swiper.min.js" and "swiper.min.css" in the root of the working folder for the following examples to work.Otherwise use the CDN link as given below in your following example codes.Design the HTML document with div element with class "swiper-container" which contains div elements holding images to be used for sliding with class "swiper-slide".Use HTML <img> src attribute for uploading images.In the script part of the code, initialize the swiper() method using the plugin. Set the different options as per the application's need.In the style part of the code, we have used embedded style for designing the HTML elements with the class "swiper-container" and "swiper-slide" and body element.Refer to different CSS display properties for implementation.CDN links:<link rel="stylesheet" href="https://unpkg.com/swiper@7/swiper-bundle.min.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"> </script> <script src="https://unpkg.com/swiper@7/swiper-bundle.min.js"></script>Example 1: The following example demonstrates a basic slider using the Swiper plugin. Other attributes of the plugin can also be set as per the need. The page is designed with HTML div elements with the plugin's classes namely "swiper-container", "swiper-wrapper", "swiper-slide", "swiper-pagination" and other classes. Use the HTML img element for inserting various images for the slider. The slider is initialized in the script part of the below code with options setting. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Implementing Swiper</title> <!-- Link Swiper's CSS --> <link rel="stylesheet" href= "https://unpkg.com/swiper@7/swiper-bundle.min.css" /> <script src= "http://code.jquery.com/jquery-1.9.1.min.js"> </script> <script src= "https://unpkg.com/swiper@7/swiper-bundle.min.js"> </script> <!-- Styles --> <style> html, body { position: relative; height: 100%; } body { font-family: Helvetica Neue; color: #000; margin: 0; padding: 0; } .swiper-container { width: 100%; height: 100%; } .swiper-slide { background: #fff; display: -ms-flexbox; display: -webkit-flex; -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; -webkit-align-items: center; } </style> </head> <body> <!-- Swiper --> <div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide"> <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20211203190050/background1.jpg"> </div> <div class="swiper-slide"> <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20211203190136/background2.jpg"> </div> <div class="swiper-slide"> <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20211203190200/background3.jpg"> </div> <div class="swiper-slide"> <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20211203190222/background4.jpg"> </div> </div> <div class="swiper-pagination"></div> <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> <div class="swiper-scrollbar"></div> </div> <!-- Initialize Swiper --> <script> var swiper = new Swiper('.swiper-container', { pagination: { el: '.swiper-pagination', }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, scrollbar: { el: '.swiper-scrollbar', } }); </script> </body> </html> Output:Example 2: In the following example, we just change or adjust the options values for the attributes in the script part of the code for the above HTML code. The developer can change or add according to the application's need. Two slides are visible at one time with a progress bar in the top and bottom of the slider. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Implementing Swiper</title> <!-- Link Swiper's CSS --> <link rel="stylesheet" href= "https://unpkg.com/swiper@7/swiper-bundle.min.css" /> <script src= "http://code.jquery.com/jquery-1.9.1.min.js"> </script> <script src= "https://unpkg.com/swiper@7/swiper-bundle.min.js"> </script> <!-- Styles --> <style> html, body { position: relative; height: 100%; } body { font-family: Helvetica Neue; color: #000; margin: 0; padding: 0; } .swiper-container { width: 100%; height: 100%; } .swiper-slide { background: #fff; display: -ms-flexbox; display: -webkit-flex; -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; -webkit-align-items: center; } </style> </head> <body> <!-- Swiper --> <div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide"> <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20211203190050/background1.jpg"> </div> <div class="swiper-slide"> <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20211203190136/background2.jpg"> </div> <div class="swiper-slide"> <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20211203190200/background3.jpg"> </div> <div class="swiper-slide"> <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20211203190222/background4.jpg"> </div> </div> <div class="swiper-pagination"></div> <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> <div class="swiper-scrollbar"></div> </div> <!-- Initialize Swiper --> <script> var swiper = new Swiper('.swiper-container', { slidesPerView: 2, centeredSlides: true, pagination: { el: '.swiper-pagination', type: 'progressbar', slidesPerView: 'auto', initialSlide: 1, resistanceRatio: 0, clickable: true }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, scrollbar: { el: '.swiper-scrollbar', }, mousewheel: true, }); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to design mobile touch slider using Swiper.js Plugin ? G geetanjali16 Follow Improve Article Tags : HTML CSS-Properties jQuery-Plugin HTML-Questions jQuery-Questions +1 More Similar Reads HTML Tutorial HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It tells the web browser how to display text, links, images, and other forms of multimedia on a webpage. HTML sets up the basic structure of a website, and then CSS and JavaScript 11 min read HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML 14 min read Top 10 Projects For Beginners To Practice HTML and CSS Skills Learning to code is an exciting journey, especially when stepping into the world of programming with HTML and CSSâthe foundation of every website you see today. For most beginners, these two building blocks are the perfect starting point to explore the creative side of web development, designing vis 8 min read HTML Introduction HTML stands for Hyper Text Markup Language, which is the core language used to structure content on the web. It organizes text, images, links, and media using tags and elements that browsers can interpret. As of 2025, over 95% of websites rely on HTML alongside CSS and JavaScript, making it a fundam 6 min read HTML Tags - A to Z List HTML Tags are fundamental elements used to structure and format content on web pages. They provide instructions to web browsers on how to render text, images, links, and other media.HTML tags are enclosed in angle brackets < > and usually come in pairs: an opening tag and a closing tag. The cl 15+ min read HTML DOCTYPE Declaration HTML DOCTYPE (Document Type Declaration) is an instruction that appears at the beginning of an HTML document, before the <html> tag.Its primary role is to tell the web browser which version of HTML the page is written in, ensuring that the browser renders the content correctly. It is not an HT 4 min read 30+ Web Development Projects with Source Code [2025] Web development is one of the most in-demand career paths in the IT industry, experiencing consistent growth of around 20â25% annually. Whether you're a student starting out or an experienced professional looking to switch or advance your career, it's essential to go beyond theory and demonstrate yo 4 min read Frontend Developer Interview Questions and Answers Frontend development is an important part of web applications, and it is used to build dynamic and user-friendly web applications with an interactive user interface (UI). Many companies are hiring skilled Frontend developers with expertise in HTML, CSS, JavaScript, and modern frameworks and librarie 15+ min read HTML Forms HTML forms, defined using the <form> Tags are essential for collecting user input on web pages. They incorporate a variety of interactive controls such as text fields, numeric inputs, email fields, password fields, checkboxes, radio buttons, and submit buttons. Over 85% of websites rely on for 5 min read HTML Tables HTML (HyperText Markup Language) is the standard markup language used to create and structure web pages. It defines the layout of a webpage using elements and tags, allowing for the display of text, images, links, and multimedia content. As the foundation of nearly all websites, HTML is used in over 10 min read Like