Home > Article > Web Front-end > How to hide scroll bars in css
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.
<div class="outer-container"> <div class="inner-container"> <div class="content"> ...... </div> </div> </div>
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!