scrollIntoView Scrolls just too far

前端 未结 21 2099
盖世英雄少女心
盖世英雄少女心 2020-12-07 10:08

I have a page where a scroll bar containing table rows with divs in them is dynamically generated from the database. Each table row acts like a link, sort of like you\'d see

21条回答
  •  心在旅途
    2020-12-07 10:51

    If it's about 10px, then I guess you could simply manually adjust the containing div's scroll offset like that:

    el.scrollIntoView(true);
    document.getElementById("containingDiv").scrollTop -= 10;
    

提交回复
热议问题