【问题标题】:Bootstrap 3.3.4 carousel: left/right controls collides with smooth page scroll scriptBootstrap 3.3.4 轮播:左/右控件与平滑页面滚动脚本冲突
【发布时间】:2015-10-26 15:35:52
【问题描述】:

我的引导轮播的左右控制脚本与平滑页面滚动脚本发生冲突。

我确实测试了在 stackoverflow 中找到的另一个解决方案。轮播工作正常,但流畅的页面滚动确实停止工作。

原来的工作卷轴:

 <script>
  $(function() {
  $('a[href*=#]:not([href=#])').click(function() {
  if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')  && location.hostname == this.hostname) {

    var target = $(this.hash);
    target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
    if (target.length) {
      $('html,body').animate({
        scrollTop: target.offset().top
      }, 500);
      return false;
     }
   }
  });
 });
</script>

破坏页面平滑滚动的stackoverflow“解决方案”:

Change:

$('a[href*=#]:not([href=#])').click(function() {

to (if you use the ID header-menu):

$('#header-menu a[href*=#]:not([href=#])').click(function() {

or (if you use the class header-menu):

$('.header-menu a[href*=#]:not([href=#])').click(function() {

错误解决方案的网址:click here

我想知道如何让 carousel 和 smooth scoll 同时工作。

【问题讨论】:

    标签: twitter-bootstrap carousel smooth-scrolling


    【解决方案1】:

    我确实在 Stackoverflow 中找到了这个解决方案。

    变化:

     $('a[href*=#]:not([href=#])').click(function() {
    

    到:

     $('a[href*=#]:not([href=#]):not(.carousel-control)').click(function () {
    

    解决方案是一条评论,因此它从未被标记为正确的。这是主题:

    Click Here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-02
      • 2017-12-06
      • 1970-01-01
      • 2014-03-14
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      相关资源
      最近更新 更多