scrollIntoView scrollIntoViewIfNeeded


$('input').on('click', function () {
var target = this;
setTimeout(function(){
target.scrollIntoView(true);
},100);
});

 

 

 

behavior 可选定义动画过渡效果, "auto"或 "smooth" 之一。默认为 "auto"

block 可选定义垂直方向的对齐, "start""center""end", 或 "nearest"之一。默认为 "start"

inline 可选定义水平方向的对齐, "start""center""end", 或 "nearest"之一。默认为 "nearest"

示例

var element = document.getElementById("box");

element.scrollIntoView();
element.scrollIntoView(false);
element.scrollIntoView({block: "end"});
element.scrollIntoView({behavior: "instant", block: "end", inline: "nearest"});
posted @ 2020-03-18 23:04  mrt_yy  阅读(299)  评论(0编辑  收藏  举报