0
使用这个jQuery的:https://github.com/JamyGolden/PlusAnchorjQuery的滚动偏移量
我期待使其滚动到锚特异性,但给它一个顶部50像素的偏移。我有一个50px的固定标题,当页面滚动时,标题覆盖部分的一部分。
任何帮助或正确的方向点赞赏。
感谢
我的代码:
<script type="text/javascript">
$(document).ready(function(){
$('body').plusAnchor({
easing: 'easeInOutExpo',
speed: 800,
onInit: function(base) {
if (base.initHash != '' && $(base.initHash).length > 0) {
window.location.hash = 'hash_' + base.initHash.substring(1);
window.scrollTo(0, 0);
$(window).load(function() {
timer = setTimeout(function() {
$(base.scrollEl).animate({
scrollTop: $(base.initHash).offset().top
}, base.options.speed, base.options.easing);
}, 500); // setTimeout
}); // window.load
}; // if window.location.hash
} // onInit
});
});
</script>
不能用越好的jQuery插件scrollTo? http://flesler.blogspot.it/2007/10/jqueryscrollto.html – sbaaaang
我可以但这对我来说工作得很好,它更小。开发人员回应我的github问题,并已解决。尽管感谢您的回复。 – bskool