简体   繁体   中英

zslider javascript should work only in screen resolution below 768px

i want to use zslider javascript in my website, but can any one tell me how to make it work only in screen resolution below 768px

Here is the zslider script link:

http://www.cssscript.com/demo/mobile-friendly-content-carousel-slider-with-pure-javascript-zslider/

Use media queries to show slider content below 768px:

@media (min-width: 768px) {
  .z-slide-wrap {
   display: none;
   }
}

Than use JavaScript to initialize slider only if width is below 768px:

if (window.innerWidth <= 768) {
  var slider1 = new Slider('#demo', '.z-slide-item', {
      // OPTIONS HERE
  });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM