7

我正在使用以下内容滚动到<li>无序列表中的最后一个:

$("html,body").animate({scrollTop: $('ul#cart-items li').offset().top});

如何将其更改为滚动到<li>无序列表中的最后一个,但还要从顶部偏移大约 30px?

4

2 回答 2

11

你有没有试过这个:

$("html,body").animate({scrollTop: $('ul#cart-items li:last').offset().top - 30});

但是 + 或 - 最后的 30 来实现您想要的偏移量?

于 2011-12-01T00:02:32.677 回答
1
$("html,body").animate({scrollTop: $('ul#cart-items li:last').offset().top+30});

这里是..

于 2011-12-01T00:02:09.113 回答