I have a Bootstrap website with a <select>
element inside a modal.
My problem is that in iOS (tried on iPhone 5) when I try to open the select
to choose an option
the background content (behind modal) automatically scrolls up to the top of the page.
I get this error on Safari and Google Search, instead no error on Chrome and Mercury Browser.
Does anyone know the reason and the solution of this problem? Thanks
iPhone has had this feature for a long time, but many users aren't aware of it. You can tap the clock in the status bar to scroll to top in any app on your iPhone. If you have a iPhone X or newer devices, the ones with a “notch”, you can tap on either sides of the notch to scroll to the top.
If you use an external keyboard, ⌘ cmd ↓ will scroll to the bottom of the page, and ⌥ opt ↓ will scroll one page down.
Enable automatic scrolling 1) Enter Presenter Mode. 2) Tap the Aa button from the top right. 3) Move the slider next to Auto Scroll which should turn orange. 4) Optionally move the slider beneath that to adjust the speed of the scroll.
I have the same issue and found solution that really solves this problem:
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);
});
}
Hope this would be helpful for others who will have same problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With