用容器.scrollTop,要有动画效果可以用jquery anmate属性来实现,示例如下
<div style="height:700px">1111</div>
<div style="width:100%;height:300px;overflow:auto">
<div style="height:700px">1111</div>
<div style="height:700px">222</div>
<div style="height:700px" id="dv">333</div>
</div>
<input type="button" value="scrollIntoView" onclick="scrollIntoView1()" /> <input type="button" value="jQuery.animate" onclick="jqAnimate()" />
<div style="height:700px">bbbb</div>
<script src="https://g.csdnimg.cn/??lib/jquery/1.12.4/jquery.min.js"></script>
<script>
function scrollIntoView1() {
document.querySelector('#dv').scrollIntoView({
behavior: "smooth",
block: "start"
})
}
function jqAnimate() {
var el = document.querySelector('#dv')
$(el).parent().animate({scrollTop:el.offsetTop-el.offsetHeight-20},500)
}
</script>
有帮助麻烦点下【采纳该答案】,谢谢~~