Do you want to add Multiple image sliders on same or single page using jQuery ?
One of my clients website needed to be fixed as they gave us requirements to create multiple image sliders in same page to display popular products, recent products and featured products in the homepage.
I tried couple of sliders that are popular among the internet for a while. I tried using jssor slider but still had a lot of confusion in it, yet being this as a most incredible sliders till now it was no use to me.
Then, i switched back to owl carousel. It was very clean and easy to use. It even have straight documentation to start using it. If you want to read more about it you may want to take a look at their official site.
Without doing much delay lets integrate and use multiple image slider in single page or one page using jQuery and owl carousel.
Step 1 :
- Download Owl Carousel from here.
- Download Bootstrap from here. I have Used bootstrap as my designing arsenal.
Step 2:
Make your HTML files and webpage ready. Lets first import CSS files.
1 2 3 4 |
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="css/bootstrap-theme.min.css" rel="stylesheet" type="text/css" /> <link href="style.css" rel="stylesheet" type="text/css" /> <!-- My Custom Css --> <link href="css/owl.carousel.css" rel="stylesheet"> |
Step 3:
My Custom style.css
for slight change in design. Implement if you want.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
*{ margin:0 auto; padding:0; padding-top: 5px; border:0; } .course .thumb img{ width:200px; height:200px; transition: all 1s ease; -moz-transition: all 1s ease; -ms-transition: all 1s ease; -webkit-transition: all 1s ease; -o-transition: all 1s ease; } .course img:hover{ transform: scale(1.8); -moz-transform: scale(1.8); -webkit-transform: scale(1.8); -o-transform: scale(1.8); -ms-transform: scale(1.8); overflow:hidden; } .course{ width:220px !important; border:1px solid #ccc; text-align:center; padding:10px; overflow:hidden; } |
Step 4:
Create a div
with a class container
which will automatically adjusted by the bootstrap CSS
. Take a look below at the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
<div class="container display" style="min-height:300px;"> <div class="customNavigation pull-right" style="padding-bottom:10px;"> <a class="btn prev btn-default"><span class="glyphicon glyphicon-chevron-left"></span></a> <a class="btn next btn-default"><span class="glyphicon glyphicon-chevron-right"></span></a> </div> <div id="owl-carousel" class="owl-carousel owl-theme"> <div class="course"> <div class="thumb"> <a href="products.html"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> </div> </div> <div class="container display" style="min-height:300px;"> <div class="customNavigation pull-right" style="padding-bottom:10px;"> <a class="btn prev1 btn-default"><span class="glyphicon glyphicon-chevron-left"></span></a> <a class="btn next1 btn-default"><span class="glyphicon glyphicon-chevron-right"></span></a> </div> <div id="owl-carousel1" class="owl-carousel owl-theme"> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> <div class="course"> <div class="thumb"> <a href="#"><img src="images/d.jpg" alt=""></a> </div> <div class="text"> <h4>Product Name</h4> <h5>Description</h5> <div class="price">Price</div> <div class="rating"> <span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span> </div> <div class="course-detail-btn"> <a href="#" class="btn btn-sm btn-default">Add to cart</a> <a href="#" class="btn btn-sm btn-default wishlist">Add to wishlist</a> </div> </div> </div> </div> </div> |
Step 5:
- Put an image named
d.jpg
in your root images folder. - Import jQuery library and OWL Carousel plugin in your webpage.
1 2 3 4 |
<script src="js/jquery.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/owl.carousel.js"></script> <script src="js/functions.js"></script> |
3. Copy these codes into your function.js
file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
// JavaScript Document $(document).ready(function() { if($("#owl-carousel").length){ var owl = $("#owl-carousel"); owl.owlCarousel({ items : 5, //10 items above 1000px browser width itemsDesktop : [1000,3], //5 items between 1000px and 901px itemsDesktopSmall : [900,3], // betweem 900px and 601px itemsTablet: [600,2], //2 items between 600 and 0 itemsMobile : [480,2] // itemsMobile disabled - inherit from itemsTablet option }); // Custom Navigation Events $(".next").on('click',function(){ owl.trigger('owl.next'); }) $(".prev").on('click',function(){ owl.trigger('owl.prev'); }); } if($(".chart").length){ $('.chart').easyPieChart({}); } if($(".accordion_cp").length){ //custom animation for open/close $.fn.slideFadeToggle = function(speed, easing, callback) { return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback); }; $('.accordion_cp').accordion({ defaultOpen: 'section1', cookieName: 'nav', speed: 'slow', animateOpen: function (elem, opts) { //replace the standard slideUp with custom function elem.next().stop(true, true).slideFadeToggle(opts.speed); }, animateClose: function (elem, opts) { //replace the standard slideDown with custom function elem.next().stop(true, true).slideFadeToggle(opts.speed); } }); } }); $(document).ready(function() { if($("#owl-carousel1").length){ var owl = $("#owl-carousel1"); owl.owlCarousel({ items : 5, //10 items above 1000px browser width itemsDesktop : [1000,3], //5 items between 1000px and 901px itemsDesktopSmall : [900,3], // betweem 900px and 601px itemsTablet: [600,2], //2 items between 600 and 0 itemsMobile : [480,2] // itemsMobile disabled - inherit from itemsTablet option }); // Custom Navigation Events $(".next1").on('click',function(){ owl.trigger('owl.next'); }) $(".prev1").on('click',function(){ owl.trigger('owl.prev'); }); } if($(".chart").length){ $('.chart').easyPieChart({}); } if($(".accordion_cp").length){ //custom animation for open/close $.fn.slideFadeToggle = function(speed, easing, callback) { return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback); }; $('.accordion_cp').accordion({ defaultOpen: 'section1', cookieName: 'nav', speed: 'slow', animateOpen: function (elem, opts) { //replace the standard slideUp with custom function elem.next().stop(true, true).slideFadeToggle(opts.speed); }, animateClose: function (elem, opts) { //replace the standard slideDown with custom function elem.next().stop(true, true).slideFadeToggle(opts.speed); } }); } }); |
Click here to see the demo.
If you confused on how it works, why not download whole source code. Download
Leave a Reply