1
最近在个人网站上工作,并使用jQuery ScrollTop来动画我的内容div。但我遇到了一个问题。ScrollTop奇怪的填充
1:没有在每一个参与
第二顶奇怪的填充:滚动并不一致,即。它不会每次都滚动相同的高度。
您可以在这里看到的页面:http://mnpwr.dk/v2/index.html
- 我加了一个红色边框,所以它会更容易看到问题。
jQuery的:
jQuery.noConflict();
jQuery(document).ready(function() {
getHash();
});
// Keep track of our current state
currentSection = 1;
function getHash() {
jQuery('.scroll').on('click', function() {
// Get our new state
var gethash = jQuery(this).attr('class').split(' ')[0];
// Calculate the difference, with element height of 500px using formular dest = (newPows - currentPos) * elmHeight
var scrollTop = (gethash - currentSection) * 500
jQuery('#contentDiv').animate({
scrollTop: scrollTop
}, 500);
return false;
});
}
谢谢,无法相信我错过了。这只能回答我的一个问题。它似乎仍然不会每次都滚动相同的长度。他们滚动你的菜单进一步下降。 – 2013-02-08 12:46:29
@Köd我在我的回答中解释了你的第二个问题。 – 2013-02-08 12:57:33
事实上,利润率决定了一切,边界只是为了显示问题;)现在一切都很好,谢谢!只是想知道,你会如何建议使用.offset(),我可能会再次使用它。 – 2013-02-08 13:06:56