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

How to hide scroll bars in css

醉折花枝作酒筹
醉折花枝作酒筹 Original
2021-04-22 18:09:39 21421browse

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}

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.

......

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; }

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!

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