I have a command using divName.scroll in javascript and I want this command to scroll a scrollable html div but it is scrolling to the top and not to the desired element follows the code:
divName.scroll({
top: elementName,
behavior: "smooth"
})
Remembering that it is a scrollable div, inside a div with
display: block ;
inside a div
display: flex;
position: fixed;
CodePudding user response:
Seems like you may have set your top
to the name of another element, when it expects a number of pixels?
Try:
divName.scroll({
top: 100,
behavior: "smooth"
})
https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll seems to indicate a number should work.
CodePudding user response:
If you have any content in Div you can use overflow to get scroll option.
`divName{display: flex; position: fixed;overflow: scroll;}`