How to scroll within an overflow hidden div to a certain currently invisible element?

前端 未结 2 437
时光取名叫无心
时光取名叫无心 2020-12-10 03:05

I have a list of elements within a overflow hidden div. So not all elements are visible. Now, if an element gets activated, it should become visible within the div.

2条回答
  •  猫巷女王i
    2020-12-10 03:24

    Maybe you are looking for scrollIntoView method.

    scrollToEl[0].scrollIntoView();
    

    DEMO: http://jsfiddle.net/yuFk5/14/

提交回复
热议问题