一直觉得 bootstrap 的轮播用起来很好用,代码简单,又支持响应式,

  但从未想过也不知道 bootstrap 的轮播竟然不支持在手机上左右滑动

 

  解决方法就是:

  使用滑动手势 js 插件:hammer.js(百度CDN资源库链接:http://cdn.code.baidu.com/

  然后在head中加载以后,通过 js 把 swipe 功能调用出来就可以了,下面是 js 命令调用 hammer.js 中的 swipe 功能代码

<script>
        $(function() {
            var myElement = document.getElementById('carousel-example-generic')
            var hm = new Hammer(myElement);
            hm.on("swipeleft", function() {
                $('#carousel-example-generic').carousel('next')
            })
            hm.on("swiperight", function() {
                $('#carousel-example-generic').carousel('prev')
            })
        })
</script>

 

 

  原文出处链接http://www.cnblogs.com/ytkah/p/5624142.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
猜你喜欢
  • 2021-07-14
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案