Simple and cool image slider on your HTML page using CSS and slider.js

As a web developer one always wondering about how to put a simple but  attractive image slider on their website's home page, specially when they own an e-commerce like website.
                                           So, here i am going to show you a very simple image slider with a javaScript plugin called swiper plugin. You can check their github repository here.




You need to download plugin from swiper-master github repository (download link may be found in below download section), and link your html with js and css file as mentioned below.

File name : index.html
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Image Slider</title>
  5.   <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
  6. <link rel="stylesheet" type="text/css" href="swiper.min.css">
  7. <link rel="stylesheet" type="text/css" href="style.css">
  8. </head>
  9. <body>
  10. <!-- Swiper -->
  11.   <div class="swiper-container">
  12.     <div class="swiper-wrapper">
  13.       
  14.       <div class="swiper-slide">
  15.       <div class="imgBx">
  16.       <img src="img1.jpg">
  17.       </div>
  18.       <div class="details">
  19.       <h3>Gaurav<br/><span>Web Designer</span></h3>
  20.       </div>
  21.       </div>

  22.       <div class="swiper-slide">
  23.       <div class="imgBx">
  24.       <img src="img1.jpg">
  25.       </div>
  26.       <div class="details">
  27.       <h3>Gaurav<br/><span>Web Designer</span></h3>
  28.       </div>
  29.       </div>

  30.       <div class="swiper-slide">
  31.       <div class="imgBx">
  32.       <img src="img1.jpg">
  33.       </div>
  34.       <div class="details">
  35.       <h3>Gaurav<br/><span>Web Designer</span></h3>
  36.       </div>
  37.       </div>

  38.       <div class="swiper-slide">
  39.       <div class="imgBx">
  40.       <img src="img1.jpg">
  41.       </div>
  42.       <div class="details">
  43.       <h3>Gaurav<br/><span>Web Designer</span></h3>
  44.       </div>
  45.       </div>

  46.       <div class="swiper-slide">
  47.       <div class="imgBx">
  48.       <img src="img1.jpg">
  49.       </div>
  50.       <div class="details">
  51.       <h3>Gaurav<br/><span>Web Designer</span></h3>
  52.       </div>
  53.       </div>

  54.       <div class="swiper-slide">
  55.       <div class="imgBx">
  56.       <img src="img1.jpg">
  57.       </div>
  58.       <div class="details">
  59.       <h3>Gaurav<br/><span>Web Designer</span></h3>
  60.       </div>
  61.       </div>

  62.       <div class="swiper-slide">
  63.       <div class="imgBx">
  64.       <img src="img1.jpg">
  65.       </div>
  66.       <div class="details">
  67.       <h3>Gaurav<br/><span>Web Designer</span></h3>
  68.       </div>
  69.       </div>
  70.       </div>
  71.     <!-- Add Pagination -->
  72.     <div class="swiper-pagination"></div>
  73.   </div>
  74. </body>
  75. <script type="text/javascript" src="swiper.min.js"></script>
  76. <script>
  77.     var swiper = new Swiper('.swiper-container', {
  78.       effect: 'coverflow',
  79.       grabCursor: true,
  80.       centeredSlides: true,
  81.       slidesPerView: 'auto',
  82.       coverflowEffect: {
  83.         rotate: 50,//60
  84.         stretch: 0,
  85.         depth: 100,//500
  86.         modifier: 1,//5
  87.         slideShadows : true,
  88.       },
  89.       pagination: {
  90.         el: '.swiper-pagination',
  91.       },
  92.     });
  93.   </script>
  94. </html>
File name : style.css
  1. body 
  2. {
  3.   background: #262626;
  4.   font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
  5.   font-size: 14px;
  6.   color:#000;
  7.   margin: 0;
  8.   padding: 0;
  9. }
  10. .swiper-container
  11. {
  12.   width: 100%;
  13.   padding-top: 20px;
  14.   padding-bottom: 50px;
  15. }
  16. .swiper-slide {
  17.   background-position: center;
  18.   background-size: cover;
  19.   width: 300px;
  20.   height: 380px;
  21.   background:#fff;
  22. }
  23. .swiper-slide .imgBx
  24. {
  25.   width:100%;
  26.   height:300px;
  27.   overflow:hidden;
  28. }
  29. .swiper-slider .imgBx img
  30. {
  31.   width:100%;
  32. }
  33. .swiper-slide .details
  34. {
  35.   box-sizing: border-box;
  36.   font-size:20px;
  37.   padding:20px;
  38. }
  39. .swiper-slide .details h3
  40. {
  41.   margin:0;
  42.   padding:0;
  43.   font-size:20px;
  44.   text-align:center;
  45.   line-height:20px;
  46. }
  47. .swiper-slide .details h3 span
  48. {
  49.   font-size:16px;
  50.   color:#f44336;
  51. }
Download section : Download or (https://drive.google.com/open?id=18PfoMzGMe8xw5hRoaH9MMmoZp54w2a_j)

Working Demo : Here or ( http://paymentmanager.000webhostapp.com/swiper-master/index.html)

Comments

Popular posts from this blog

Jasper report integration in Spring boot/Spring MVC.

FireBase Crud operation in Spring Boot

Xero Developer account setup with REST API auth flow.