选择元素会导致滚动到iOS设备上的页面顶部

我有一个Bootstrap网站,其中包含< select>元素内部模态.

我的问题是,在iOS(尝试在iPhone 5)当我尝试打开选择选择一个选项背景内容(模态后)自动滚动到页面的顶部.

我在Safari和Google搜索中收到此错误,而Chrome和Mercury Browser上没有错误.

有人知道这个问题的原因和解决方法吗?谢谢

解决方法

我有同样的问题,找到解决方案,真正解决了这个问题:
if( navigator.userAgent.match(/iPhone|iPad|iPod/i) ) {

    $('.modal').on('show.bs.modal',function() {

        // Position modal absolute and bump it down to the scrollPosition
        $(this)
            .css({
                position: 'absolute',marginTop: $(window).scrollTop() + 'px',bottom: 'auto'
            });

        // Position backdrop absolute and make it span the entire page
        //
        // Also dirty,but we need to tap into the backdrop after Boostrap 
        // positions it but before transitions finish.
        //
        setTimeout( function() {
            $('.modal-backdrop').css({
                position: 'absolute',top: 0,left: 0,width: '100%',height: Math.max(
                    document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight
                ) + 'px'
            });
        },0);
    });
}

希望对有同样问题的人有帮助.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...