4

How do I, with Vue, scroll down a div to a specific place? I have a list < li > inside a < div > and I want Vue automatically to scroll down to the active item. I know the height of each item, so it's basically x position from top.

1 Answer 1

4

position div to X location

basicly change such div's top value.

document.getElementById("myDiv").style.top = "100px";

scroll entire page to X coordinate:

first number is x another y. So if you know position - just

window.scrollTo(x-coord, y-coord)

https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Guess that's the way to do it with v-el.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.