【发布时间】:2015-06-15 07:59:00
【问题描述】:
我正在使用以下脚本来实现锚标签的平滑滚动效果:
$(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
}, 1000);
return false;
}
}
});
});
使用此脚本后,Bootstrap Carousel 的左右控件停止工作。
<a class="left carousel-control" href="#home-carousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#home-carousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
我该如何解决这个问题?
【问题讨论】:
-
你使用平滑滚动效果的锚标签是什么,或者只是一个菜单?
-
@brance 只是菜单
-
您的菜单 div 是否有 id,例如 #menu 或类似的东西?
-
是的。我正在为它使用 header-menu 标记
标签: javascript jquery twitter-bootstrap carousel