Home > Web Front-end > CSS Tutorial > How Can I Prevent Scrolling and Hide Content Beyond the Viewport on iOS Devices?

How Can I Prevent Scrolling and Hide Content Beyond the Viewport on iOS Devices?

Linda Hamilton
Release: 2024-12-14 08:45:15
Original
930 people have browsed it

How Can I Prevent Scrolling and Hide Content Beyond the Viewport on iOS Devices?

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;
}
Copy after login

For iOS 9, you might need this instead:

html,
body {
    overflow: hidden;
    position: relative;
    height: 100%;
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template