Home >Web Front-end >CSS Tutorial >How to Effectively Disable Scrolling in Mobile Safari?

How to Effectively Disable Scrolling in Mobile Safari?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-05 17:43:11175browse

How to Effectively Disable Scrolling in Mobile Safari?

Disabling Scrolling on Mobile Safari: Overcoming Platform-Specific Quirks

When working with long web pages on mobile Safari, it can be desirable to prevent users from scrolling past the initial visible content. However, applying overflow:hidden to the element doesn't always achieve this effect on this particular platform.

To resolve this issue, a solution that has proven effective is to apply overflow:hidden to both the html and body elements. This approach effectively controls scrolling behavior on mobile Safari:

html, body {
    overflow: hidden;
}

However, if you're working with iOS 9 specifically, you may encounter a slight variation in the necessary code:

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

These adjustments ensure that scrolling is disabled beyond the visible portion of the page on mobile Safari, enabling you to achieve the desired layout and user experience.

The above is the detailed content of How to Effectively Disable Scrolling in Mobile Safari?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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