//要控制的元素
var result = $(".result-container");
if (result.length) {
$('html, body').animate({scrollTop: result.offset().top},1000)
console.log(result.offset().top)
}
//后面scrollTop的属性值 result.offset() 是获取元素相对页面的位置里面有两个属性 top和left, 元素的margin 也算相对页面的位置
原文链接:https://blog.csdn.net/qq_44576005/article/details/111210369