CSS implementation No (hidden) scroll bar page

Source: Internet
Author: User

Implementation function: Hide browser scroll bar, and do not affect the mouse wheel scrolling page
Applicable: With large picture as background or product introduction page (It should work better if it works with Parallax scrolling .)
Required technology: Very simple CSS and JS

First look at the contrast effect (fig. 1 = Figure 2, both of which can scroll through the mouse wheel for content)


(Fig. 1)


(Fig. 2)

You can see clearly that the body width of Figure 2 is significantly smaller than the width of Figure 1 and has a right offset.
This is the basic principle of no scroll bar page: Moves (sets) the offset of the body (margin/padding),causes the body's scrollbar to appear outside the range of the parent nodeTo achieve the effect of no scroll bar

Code implementation
An HTML node can be divided into 3 levels:

Window
| -Container
| -Text
Such as


And then, with a simple CSS setting, you can achieve no scroll bar effect.
Window needs to be set:Overflow:hidden

Container needs to be set:overflow-y:scroll, height (fixed height), margin (Padding/relateiv+left also line)


If the width of the body is the same as the width of the browser, you need to calculate the width of the browser in real time by JS and set
width of the container = browser width + 20px (width of the general browser scroll bar)
(Of course, there are some CSS details, need to adjust according to the specific situation)

TIP: After you hide the scrollbar in this way, the Onscroll event cannot be set on the window, but is set on the container

CSS implementation No (hidden) scroll bar page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.