Mobile Body Settings Overflow:hidden The page will scroll up after the expiration and setup.

Source: Internet
Author: User

Recently in the writing of a multi-pop window page, found that when the pop-up window appears when the bottom page will be scrolling through the phenomenon, so think of when the pop-up window display and hide the JS dynamic Control body Overflow property values, that is

$ ("Body"). CSS ("Overflow", "hidden"); $ ("body"). CSS ("Overflow", "visible");

In the browser-side debugging is able to achieve the desired effect, the results in the mobile side whether iOS or Android system are not valid, in the degree Niang view of the predecessors of the relevant blog learned that this is a mobile browser features, to solve this problem online there are three ways

1.body plus position:fixed;width:100%;height:100%; 2. Add a parent to the element you want to scroll, set the height, Overflow:auto3.html,body{height:100%;overflow:hidden}

I used the third method, proved to be very effective, but at this time there is another problem, when the pop-up window is the body is forbidden to scroll when the first scroll to the top, so if the user triggers the popup event element position at the bottom of the page, then the experience is very bad, My workaround is to get the page scrolling position when the page is blocked, allowing the page to scroll to its original location

get page scroll position var scrolltotop=$ (window). scrolltop; Set page scroll position $ (' body,html '). scrolltop (Scrolltotop);

At the very beginning, I used $ (' body '). ScrollTop (Scrolltotop) sets the position of the page scrolling, the results found invalid, with $ (' html '). ScrollTop (scrolltotop) is valid, in order to prevent accidents, End use of the above method

Mobile Body Settings Overflow:hidden The page will scroll up after the expiration and setup.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.