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

How to hide scroll bars in css

王林
Release: 2020-03-31 09:06:24
forward
2952 people have browsed it

How to hide scroll bars in css

Mobile terminal

The mobile page only needs to be compatible with Chrome and Safari, so you can use the pseudo-class selector of the custom scroll bar::-webkit-scrollbar to hide the scrollbar.

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

(Recommended tutorial: CSS tutorial)

PC side

The PC side has relatively higher compatibility requirements, so everything can Another way, the general idea is to wrap a parent container div outside the content div, set overflow: hidden, set the content div to display-x: hidden; display-y: auto; and finally set the width of the parent container div to be smaller than the width of the content div. Or just set the margin-right of the content div to a negative value.

<div class="outer">
    <div class="content">
      <p>1111</p>
      <p>222</p>
      <p>333</p>
      <p>444</p>
    </div>
</div>
 .outer {
   width: 300px;
   height: 300px;
   overflow: hidden;
  
   .content {
     width: 330px;
     /*margin-right: -15px;*/
     height: 100%;
     overflow-x: hidden;
     overflow-y: auto;
     background: red;
     padding-top: 100px;
  
     p:not(:first-child) {
       margin-top: 100px;
     }
   }
 }
Copy after login

Recommended related video tutorials: 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:jb51.net
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