Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击时,引导转盘向上移动_Javascript_Jquery_Html_Css_Twitter Bootstrap - Fatal编程技术网

Javascript 单击时,引导转盘向上移动

Javascript 单击时,引导转盘向上移动,javascript,jquery,html,css,twitter-bootstrap,Javascript,Jquery,Html,Css,Twitter Bootstrap,我很困惑,为什么我的页面或旋转木马在我第一次点击它时就会向上移动?这是我的代码,我从Bootstrap得到的 #提示#转盘示例{ 保证金:自动; 宽度:900px; } #提示{ 背景色:#fcb595; 最大高度:100%; } 尝试用数据目标替换控件中的href: <a class="left carousel-control" data-target="#carousel-example" data-slide="prev"> <span class=

我很困惑,为什么我的页面或旋转木马在我第一次点击它时就会向上移动?这是我的代码,我从Bootstrap得到的

#提示#转盘示例{
保证金:自动;
宽度:900px;
}
#提示{
背景色:#fcb595;
最大高度:100%;
}


  • 尝试用
    数据目标替换控件中的
    href

    <a class="left carousel-control" data-target="#carousel-example" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left"></span>
    </a>
    <a class="right carousel-control" data-target="#carousel-example" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right"></span>
    </a>
    

    我今天发现了这个问题,虽然已经很晚了,但我将为未来的访问者回答这个问题

    大多数开发人员使用一些脚本来为目标元素设置动画,就像我做的那样。我可以在你的动画图像中看到同样的问题

    $('a[href^="#"]').on('click', function(e) {
      e.preventDefault();
      //... some logic
      // eg.
      $('html, body').animate({
        scrollTop: $(this).offset().top - 100
      }, 1000, 'swing');
    });
    
    这就是转盘单击出现问题的原因。因此,为了避免此类问题,您只需返回“单击是否在转盘上”控件:

    $('a[href^="#"]').on('click', function(e) {
      if ($(this).data('slide')) return;
      e.preventDefault();
    });
    

    1.您正在使用的引导程序是什么?引导程序3和4有不同之处。2.如果您使用IE9或之前的版本来查看页面,可能会发生奇怪的事情。不确定上述问题是否是你的问题。你找到解决方案了吗?面对同样的情况,在最新版本的chrome上。你找到解决办法了吗?