Html 旋转时将网页滚动到移动设备顶部

Html 旋转时将网页滚动到移动设备顶部,html,css,twitter-bootstrap,Html,Css,Twitter Bootstrap,我有一个问题,当我的网页从纵向旋转到横向时(在iOS设备上,例如iPhone5),横向视图从页面顶部开始大约50px。向后旋转显示没有问题的纵向视图 以下是显示问题的屏幕截图: 肖像(正确): 旋转后的横向(不正确): Lanscape应如何显示: 如果要在设备上检查链接,请参见以下链接: 经过一些挖掘后,以下代码将允许在移动设备上旋转到横向视图时滚动到顶部: window.onorientationchange = function () { var orientation =

我有一个问题,当我的网页从纵向旋转到横向时(在iOS设备上,例如iPhone5),横向视图从页面顶部开始大约50px。向后旋转显示没有问题的纵向视图

以下是显示问题的屏幕截图:

肖像(正确):

旋转后的横向(不正确):

Lanscape应如何显示:

如果要在设备上检查链接,请参见以下链接:


经过一些挖掘后,以下代码将允许在移动设备上旋转到横向视图时滚动到顶部:

window.onorientationchange = function () {

    var orientation = window.orientation;

    // Look at the value of window.orientation:

    if (orientation === 0) {

        // device is in Portrait mode.

    } else if (orientation === 90) {

        // device is in Landscape mode. The screen is turned to the left.

        $('body').animate({
            scrollTop: '0'
        }, 0);

    } else if (orientation === -90) {

        // device is in Landscape mode. The screen is turned to the right.

        $('body').animate({
            scrollTop: '0'
        }, 0);

    }

};

您可能会从这篇文章中得到正确的答案,然后您可能会触发一个滚动条。@Medda86谢谢您的帮助。回答了我下面的问题。