这可能是一个简单的问题,但我需要一些帮助。
我有此代码:
var lastitem='';
(function($) {
var allPanels = $('.accordion> dd').hide();
$('.accordion > dt > a').click(function() {
allPanels.slideUp();
if ($(this).text() != lastitem) {
$(this).parent().next().slideDown();
lastitem = $(this).text();
$(this).get(0).scrollIntoView({
behavior: "smooth", // or "auto" or "instant"
block: "start" // or "end"
});
} else {
lastitem = '';
};
return false;
});
})(jQuery);
我有一个固定的标题,所以当我单击手风琴时它会滚动到视口中,问题出在我的固定标题上。我需要从顶部滚动到视口+ 100px。
类似的东西:
$(this).get(0).scrollIntoView({
behavior: "smooth", // or "auto" or "instant"
block: "start + 100px" // or "end"
});
仅此而已,有什么建议吗?谢谢!!