Home > Web Front-end > CSS Tutorial > How to hide scroll bars in css

How to hide scroll bars in css

醉折花枝作酒筹
Release: 2023-01-05 16:10:39
Original
21528 people have browsed it

How to hide the scroll bar: first use the "::-webkit-scrollbar" pseudo-class selector to select the scroll bar of the element, and then use the "display:none;" style to hide the scroll bar; specific syntax format "::-webkit-scrollbar{display:none;}".

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

You can use the pseudo-object selector of a custom scroll bar::-webkit-scrollbar to set a hidden scroll bar.

Use this pseudo-class selector to hide the scroll bar css code:

.element::-webkit-scrollbar {display:none}
Copy after login

If you want to be compatible with other PC browsers (IE, Firefox, etc.), you can use the following method. Nest another layer outside the container with overflow:hidden and then limit the size of the inner content to the same size as the outer nesting layer, so it is hidden in disguise.

<div class="outer-container">
     <div class="inner-container">
        <div class="content">
            ......
        </div>
     </div>
 </div>
Copy after login

css code:

.outer-container,.content {
	width: 200px; 
	height: 200px;
}
.outer-container {
    position: relative;
    overflow: hidden;
}
.inner-container {
    position: absolute; 
    left: 0;
    overflow-x: hidden;
    overflow-y: scroll;
}
 /* for Chrome */
.inner-container::-webkit-scrollbar {
    display: none;
}
Copy after login

Recommended learning: css video tutorial

The above is the detailed content of How to hide scroll bars in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template