Hide Content Beyond the Fold on iPhone/iPad
Disabling scrolling on mobile Safari for long pages can be a challenge. Applying overflow: hidden to the
element alone may not suffice. Here's a solution that works:Solution:
Apply overflow: hidden; to both the html and body elements:
html, body { overflow: hidden; }
For iOS 9, you might need this instead:
html, body { overflow: hidden; position: relative; height: 100%; }
This will prevent the page from scrolling and hide any content that extends beyond the viewport. Note that this solution may not be suitable for all websites, as it can break some functionalities, such as sliders or dropdowns, that rely on scrolling.
The above is the detailed content of How Can I Prevent Scrolling and Hide Content Beyond the Viewport on iOS Devices?. For more information, please follow other related articles on the PHP Chinese website!