Home > Article > Web Front-end > The mobile terminal sets the overflow:hidden method to prevent the page from scrolling.
I encountered a very embarrassing problem at work today. The following article mainly introduces to you the prohibition method of setting overflow:hidden on the mobile terminal, but the page still scrolls. The article introduces it through sample code. For details, friends who need it can refer to it. Let’s take a look below.
Preface
This article mainly introduces to you how to set overflow:hidden
on the mobile terminal and the page will still scroll The prohibition method is shared for everyone’s reference and study. I won’t go into details below, let’s take a look at the detailed introduction.
If overflow:hidden
is used in the body tag, the mobile browser can still scroll, because the mobile browser is based on touch events. There are two solutions.
Method 1:
Add a Wrap layer p, and then set the height of this p to window.height()
and overflow:hidden
to solve your problem.
Method 2:
Add position:fixed;
Example:
body { overflow:hidden; position:fixed; left:0; top:0; }
The above is the detailed content of The mobile terminal sets the overflow:hidden method to prevent the page from scrolling.. For more information, please follow other related articles on the PHP Chinese website!