Home  >  Article  >  Web Front-end  >  How to display scroll bar beyond css

How to display scroll bar beyond css

coldplay.xixi
coldplay.xixiOriginal
2021-04-16 17:25:362735browse

How to use css beyond the scroll bar display: 1. Use three containers to surround it, and there is no need to calculate the width of the scroll bar; 2. Pseudo-object selector for custom scroll bar [::webkit-scrollbar].

How to display scroll bar beyond css

The operating environment of this tutorial: windows7 system, css3 version, DELL G3 computer.

Css method for displaying scroll bars beyond the limit:

Method 1: Surrounded by three containers, there is no need to calculate the width of the scroll bar

Compared with method 1, this method adds an extra box and limits the content to the box, so that you can not see the scroll bar and can scroll at the same time.

 <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 2: Customize the pseudo-object selector of the scroll bar::webkit-scrollbar

This method is not compatible with IE and can be used for mobile applications.

1
.element::-webkit-scrollbar { width: 0 !important }
  IE 10+
1
.element { -ms-overflow-style: none; }
  Firefox
1
.element { overflow: -moz-scrollbars-none; }

Details:

The following is the custom webkit scroll bar style

Using the latest version of Google Chrome browser, the scroll bar style is already very beautiful. This webkit-scrollbar only works with webkit core.

webkit attribute

::-webkit-scrollbar { /* 1 */ }
::-webkit-scrollbar-button { /* 2 */ }
::-webkit-scrollbar-track { /* 3 */ }
::-webkit-scrollbar-track-piece { /* 4 */ }
::-webkit-scrollbar-thumb { /* 5 */ }
::-webkit-scrollbar-corner { /* 6 */ }
::-webkit-resizer { /* 7 */ }

Recommended related tutorials: CSS video tutorial

The above is the detailed content of How to display scroll bar beyond 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