问题
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