How to design mobile touch slider using Swiper.js Plugin ?
- 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.
<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>
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.
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.
Please Login to comment...