M
M
Muhammad Magomedov2019-03-06 14:00:56
css
Muhammad Magomedov, 2019-03-06 14:00:56

overflow:hidden not working on body and html on iPhone?

There is an event for opening a modal window. when opening a window, html and body should be blocked from scrolling (we use overflow:hidden), but it does not work on the iPhone and the standard xiaomi browser (maybe it does not work somewhere else, did not check). on regular android browsers works exactly
Exemplary spawn code
overflow:hidden;

$('.product_btn, .social_callback').click(function () {
    $('html, body').css('overflow', 'hidden');
});

We tried position: fixed; and position: relative;
It was also set . Either the scrolling of the body worked, as before, or the scrolling was blocked, but at the same time it was transferred to the very top of the page. This option does not suit us. How to make it so that this scroll is blocked at the body, but at the same time it does not move to the very top of the page, as it happens with ? height:100%;
height: 100%;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FeST1Val, 2019-03-06
@FeST1Val

As an option, make touch restrictions on move and start.

M
Muhammad Magomedov, 2019-03-07
@Web_Mukhammad

Tx guys. I found a solution, when opening a modal window, the following action is performed:

$('.product_btn, .social_callback').click(function () {
    var scrollX = window.scrollX;
    var scrollY = window.scrollY;
    window.onscroll = function () { window.scrollTo(scrollX, scrollY); };
  });

and cancel on closing:
$('.popup_close, .modal_close').click(function () {
    window.onscroll = function () { return; };
  });

will twitch a little, but it's better than staying with a scroll

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question