使用jQuery和引导3我正在尝试创建一个滚动网页页面。这里是Working Demo。到目前为止,它看起来罚款时,在像Section 1
到Section 2
或Section 2
到Section 3
序列用户滚动,但我对nav navbar-nav
项目一些问题,当用户滚动无序从Section 1
到Section 6
等。它看起来像每个项目nav navbar-nav
步骤获得目标项目!(你可以在下面的图片查看)滚动到部分的问题
还有另外一个重要的问题上Section 7
滚动。它不滚动到与其他部分相同的位置,并且有更多的空间。 (你可以在下面的图片查看)
这里是我用于滚动
<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
}, 1000);
return false;
}
}
});
});
</script>
能否请你帮我解决的代码,这些事情jQuery的?谢谢
感谢Preli,那么解决方案是什么? – user1760110