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;}".
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:
Above The sample output results are as follows:
(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!