【发布时间】:2016-03-03 20:46:48
【问题描述】:
我正在使用 Bootstrap,而常规导航当前使用平滑滚动脚本,该脚本可以转到页面的各个部分。
对于移动设备,我有一个全屏导航模式,一旦您单击汉堡包图标就会打开。它也将使用平滑滚动,但是一旦您单击菜单中的链接并将您带到该部分,我似乎无法关闭模式。
脚本
$(function() {
$('a[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;
}
}
});
$('#myModal').modal('hide');
});
【问题讨论】:
标签: jquery twitter-bootstrap bootstrap-modal smooth-scrolling