具有固定高度的jQuery slimScroll滚动条

时间:2013-12-03 13:02:49

标签: jquery scrollbar slimscroll

我正在使用rochal的jQuery插件slimScroll来显示自定义滚动条。有没有办法使滚动条的高度固定,而不是自动生成?我认为必须生成wheelStep值,但不知道要改变什么。所以,问题是如何制作一个固定大小的滚动条。

如果这是不可能的话,我也可以使用另一个插件。

2 个答案:

答案 0 :(得分:4)

有可能!要实现此目的,请执行以下操作:

后:

// sets border radius of the rail
railBorderRadius : '7px'

在'7px'之后添加逗号并且:

// Use a fixed height for the scroll bar
useFixedHeight : true,

// the fixed height of the scroll bar
fixedHeight : 50

替换:

barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight);

使用:

if( o.useFixedHeight )
    barHeight = o.fixedHeight;
else
    barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight);

答案 1 :(得分:1)

我尝试过一个简单的技巧..

首先向滚动条添加一个类,默认情况下是'slimScrollBar'

  
    

barClass:'slimScrollBar_new'

  
<script>
    $('#scroll-content').slimScroll({
        size : '3px',
        alwaysVisible: true,
        barClass : 'slimScrollBar_new'
    });
</script>

<style>
  .slimScrollBar_new{
      height: 100px !important;
   }
</style>