DIV Horizontal scroll, how to onload to ID

为君一笑 提交于 2021-01-29 05:11:17

问题


Have a site with MANY horizontally scrolling DIV containers. On one of the containers we want it to scroll to a certain position onLoad. Recommendations to what the best solution is?

To complicate it a little more, the container is vertically far down (i.e. below the fold) on the page and would rather not have the onLoad result in having the page scroll vertically down to this container, merely have this specific container scrolled horizontally and nothing else. Is this also possible?

Many thanks.


回答1:


You can use the scrollLeft property for this.

http://jsfiddle.net/v6EwS/

document.getElementById('foo').scrollLeft = 500;​


来源:https://stackoverflow.com/questions/9915195/div-horizontal-scroll-how-to-onload-to-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!