2

I am trying to find a way to change the scroll bar to a perfect scrollbar for the entire page

http://noraesae.github.io/perfect-scrollbar/

Any way to do so?

Slava Knyazev
  • 5,377
  • 1
  • 22
  • 43

1 Answers1

2

Make a div under the body that holds all the page's code. Give this CSS to the div:

position:absolute;
top:0px;
bottom:0px;
right:0px;
left:0px;
overflow: scroll;

Then just apply the perfect-scrollbar on the div.


A little explanation:

// Set the div's position
position:absolute; // Set the div display to be relative to the document

// Make the div cover the full page
// by setting all directions px to 0
top:0px;           // Set the div start from top
bottom:0px;        // Set the div start from bottom
right:0px;         // Set the div start from right
left:0px;          // Set the div start from left

// Set the div to show a scrollbar on overflow
overflow: scroll;
GramThanos
  • 3,572
  • 1
  • 22
  • 34
  • I do not know, sorry. – GramThanos Oct 09 '14 at 23:11
  • @ViruZX what do you mean by "scroll links"? Scroll to element by hash #? – Gromo Oct 10 '14 at 11:11
  • I would call them hashtag links. You can manage them with javascript read here http://stackoverflow.com/questions/680785/on-window-location-hash-change – GramThanos Oct 10 '14 at 15:14
  • @ViruZX Or you can use custom scrollbar that will allow using hash-links - it's easier and simplier. For example [jQuery Scrollbar](https://github.com/gromo/jquery.scrollbar) – Gromo Oct 10 '14 at 16:04
  • This particular do not display all content on my chrome, i can not move the bar to the end. (are you the creator?) – GramThanos Oct 10 '14 at 16:06
  • @gromo That seems to compromise my entire page structure. – Slava Knyazev Oct 10 '14 at 16:19
  • Look [here](http://gromo.github.io/jquery.scrollbar/) - entire page uses custom scrollbar and I do not see any issues in chrome. Yep, I'm the author of this plugin :) – Gromo Oct 10 '14 at 16:22
  • The x-bar is not going all the way to the end (Should there be a x-bar?) and y also lose some bottom px. But its smooth and nice, if you fix that. – GramThanos Oct 10 '14 at 16:25
  • @ThanasisGrammatopoulos it's designed so: X (horizontal) and Y (vertical) scrollbars should not overlap each other. If only X scrollbar is visible - it will fit all available width, the same for Y scrollbar - if there is no X scrollbar, it will fit 100% height (or height set in CSS). I think that overlapped scrollbars in plugin perfect-scrollbar is a bug. Just look at mobile/iPhone/iPad scrollbars behavior – Gromo Oct 10 '14 at 16:31
  • No its very nice the style, and i agree with you. But i have a x scroll bar here, that i can not move and it say it can be moved. – GramThanos Oct 10 '14 at 16:37
  • @ThanasisGrammatopoulos it can be easily changed via CSS. Scrollbar is fully CSS customizable, including paddings/margins that depends on other scrollbar visibility. Just update CSS below section /* update scrollbar offset if both scrolls are visible */. But if you found a bug (or you think this is a bug), please, create an issue in github, or write me description via email – Gromo Oct 10 '14 at 16:39