Search code examples
csswebkitscrollbar

Put some space between webkit scrollbar and screen edge


I've got this css code that makes a webkit scrollbar.

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

This will make a scrollbar that will be right next to the screen edge. Is there any way that I can put some space between the screen edge and the scrollbar?


Solution

  • Here is an interesting solution to what I think you are talking about; they actually put padding/position on the body element:

    body {
        position: absolute;
        top: 20px;
        left: 20px;
        bottom: 20px;
        right: 20px;
        padding: 30px; 
        overflow-y: scroll;
        overflow-x: hidden;
    }