如何在水平溢出的页面上向右滚动? [英] How do I scroll to the right on a page that overflows horizontally?
本文介绍了如何在水平溢出的页面上向右滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户关闭模态时(特别是基础4中的显示模式),我想滚动到页面的最右边缘(非常有用)。
I want to scroll to the far right edge of a page that is really wide (it's wide on purpose) when the user closes a modal (specifically, the Reveal modal in Foundation 4).
我尝试在一直对齐的div上设置一个id,但这显然不起作用。
I've tried setting an id on a div that's aligned all the way right, but that obviously doesn't work.
推荐答案
要水平滚动,请使用 scrollLeft()。
$('body, html').scrollLeft(400);
jQuery还支持动画 scrollLeft
属性。
jQuery also supports animating the scrollLeft
property.
要一直向右滚动,您将获得页面的整个宽度,并减去窗口宽度以获得左边缘:
To scroll all the way to the right, you get the full width of the page, and subtract the window width to get the left edge :
var left = $(document).outerWidth() - $(window).width();
$('body, html').scrollLeft(left);
这篇关于如何在水平溢出的页面上向右滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文