Thanks for replying, but I don't think this will do. What I am trying to achieve is scrolling into an element that is inside a container that is set to overflow scroll. I made some modifications to the code to make it even simpler to understand.
https://codepen.io/veuxon/pen/OJaxpKj
Now, when I click on the button that is supposed to make that element come to view, it just scrolls to the top or bottom, but when the element is in view, it does scroll to the top. I want to achieve this behaviour even when the element is not in view.