scrollIntoView将指定元素定位到浏览器顶部,底部,中间
var element = document.getElementById("box"); element.scrollIntoView();//顶部 element.scrollIntoView(false);//底部 element.scrollIntoView({block: "end"}); element.scrollIntoView({behavior: "instant", block: "end", inline: "nearest"});