How to hide the scroll bar in css3
The way to hide the scroll bar in css3 is to customize the pseudo-object selector of the scroll bar [::-webkit-scrollbar], such as [.element::-webkit-scrollbar { width: 0 !important } 】.
The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.
Many times we will encounter this situation at work, where we need to hide the scroll bar and support scrolling. So what should we do when encountering this situation? Maybe the first reaction of many people is to use the iscroll plug-in, but I prefer to use css to achieve this function. Let’s take a look at the specific methods below.
Method 1: Calculate the width of the scroll bar and hide it
You only need to hide the scroll bar by positioning it.
<div class="outer-container"> <div class="inner-container"> ...... </div> </div>
.outer-container{ width: 360px; height: 200px; position: relative; overflow: hidden; }.inner-container{ position: absolute; left: 0; top: 0; right: -17px; bottom: 0; overflow-x: hidden; overflow-y: scroll; }
This code cleverly moves 17 pixels to the right, which is exactly equal to the width of the scroll bar. This value was obtained by manual debugging. No problem found in chrome and IE.
Method 2: Surrounded by three containers, no need to calculate the width of the scroll bar
This code was first seen on the Microsoft blog. It is similar to the idea above, except that Another box was added to the house, limiting the content to the box. This way you can't see the scroll bar and still be able to scroll. The code is as follows:
<div class="outer-container"> <div class="inner-container"> <div class="content"> ...... </div> </div> </div>
.element, .outer-container { width: 200px; height: 200px; } .outer-container { border: 5px solid purple; position: relative; overflow: hidden; }.inner-container { position: absolute; left: 0; overflow-x: hidden; overflow-y: scroll; }.inner-container::-webkit-scrollbar { display: none; }
Method 3: CSS hidden scroll bar
Pseudo-object selector of custom scroll bar::-webkit-scrollbar.
.element::-webkit-scrollbar { width: 0 !important }
IE 10
.element { -ms-overflow-style: none; }
Firefox
.element { overflow: -moz-scrollbars-none; }
Free learning video sharing: css video tutorial
The above is the detailed content of How to hide the scroll bar in css3. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to achieve wave effect with pure CSS3? This article will introduce to you how to use SVG and CSS animation to create wave effects. I hope it will be helpful to you!

Unlike Windows 10, Windows 11 features new modern “fluid scrollbars” that change shape when users interact with them. Fluent scrollbars are dynamic in nature, they automatically scale in different form factors or when you change the window size, and it is currently used in apps like Settings, Media Players, and more. Google Chrome may soon have smooth scrollbar functionality, according to a new proposal from Microsoft. Microsoft says in a proposal that they want to modernize old scroll bars in Chrome

This article will show you how to use CSS to easily realize various weird-shaped buttons that appear frequently. I hope it will be helpful to you!

Two methods: 1. Using the display attribute, just add the "display:none;" style to the element. 2. Use the position and top attributes to set the absolute positioning of the element to hide the element. Just add the "position:absolute;top:-9999px;" style to the element.

How to hide scroll bar scrolling in react: 1. Open the corresponding "react-native" file; 2. Set horizontal scrolling through horizontal; 3. Hide the horizontal scroll bar by setting the value of "showsHorizontalScrollIndicator" to "false".

In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".

Recently, some friends have consulted the editor about how to set the scroll bar of the Mac system to always display. The following will bring you the method of setting the scroll bar of the Mac system to always display. Friends who need it can learn more. Step 1: In the system start menu, select the [System Preferences] option. Step 3: On the System Preferences page, select the [General] option. Step 3: On the general page, select [Always] to display scroll bars.

Implementation method: 1. Use the ":active" selector to select the state of the mouse click on the picture; 2. Use the transform attribute and scale() function to achieve the picture magnification effect, the syntax "img:active {transform: scale(x-axis magnification, y Axis magnification);}".
