用完美的滚动更改滚动条

时间:2014-10-09 22:32:27

标签: javascript jquery html css

我正在尝试找到一种方法将滚动条更改为整个页面的完美滚动条

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

任何方式都这样做?

1 个答案:

答案 0 :(得分:2)

在包含所有页面代码的正文下方创建一个div。将此CSS提供给div:

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

然后在div上应用完美滚动条。


一点解释:

// 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;