CSS: Possible to “push” Webkit scrollbars into content?

前端 未结 2 498
时光说笑
时光说笑 2021-02-07 06:49

Normally a scrollbar is positioned like this:

________________________________________
|                          |           |
|         content          | scro         


        
相关标签:
2条回答
  • 2021-02-07 07:43

    I think thats not possible by assigning a right margin to a right-aligned scrollbar. The scrollbar is part of the window-UI and may not be styled via CSS.

    However you can just create an content-wrapper around all other elements of your HTML, give it a max-width, which is smaller then 100% and set overflow: scroll; for the wrapper. This will achieve the desired effect and work in nearly all browsers.

    [personal opinion] I think it's a very bad habit of certain web-designers, who want to control every piece of my screen. For example the scrollbars should be styled by the window-manager not by the website I'm currently viewing.

    0 讨论(0)
  • 2021-02-07 07:44

    You can do it with a transparent border. But you need to set background-clip: padding-box; or it won't work.

    Example: http://jsfiddle.net/6KprJ/1/

    0 讨论(0)
提交回复
热议问题