Home  >  Article  >  Web Front-end  >  How to disable the left and right scroll bars of the page in css

How to disable the left and right scroll bars of the page in css

WBOY
WBOYOriginal
2021-12-02 16:37:526384browse

In CSS, you can use the "overflow-x" attribute to disable the left and right scroll bars of the page. When the value of this attribute is "hidden", you can hide the element content beyond the left and right edges, thereby disabling it. Display of scroll bars on the left and right sides of the page; the syntax is "body{overflow-x:hidden;}".

How to disable the left and right scroll bars of the page in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

How to disable the left and right scroll bars of the page in css

We can use the overflow-x attribute to hide content that exceeds the left and right width of the page. In this way, the left and right scroll bars will not appear on the page.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    body{
        overflow-x:hidden;
    }
    </style>
</head>
<body>
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</body>
</html>

If the overflow-x:hidden; style is not added to the body element, the output result is as follows:

How to disable the left and right scroll bars of the page in css

Above The sample output results are as follows:

How to disable the left and right scroll bars of the page in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to disable the left and right scroll bars of the page in css. 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