我有一个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); }); }
希望对有同样问题的人有帮助.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。