简体   繁体   English

固定高度的jQuery slimScroll滚动条

[英]jQuery slimScroll scroll bar with fixed height

I am using the rochal's jQuery plugin slimScroll to display a customized scrollbar. 我正在使用rochal的jQuery插件slimScroll显示自定义滚动条。 Is there a way to make the height of the scrollbar fixed, not autogenerated? 有没有办法使滚动条的高度固定,而不是自动生成? I think that the wheelStep value must be generated, but don't know what to change. 我认为必须生成wheelStep值,但不知道要更改什么。 So, question is how to make a fixed size scroll bar. 因此,问题是如何制作固定大小的滚动条。

Also I could use another plugin if this is imposible. 如果这不可能,我也可以使用其他插件。

It is posible! 有可能! To achieve this do the following: 为此,请执行以下操作:

After: 后:

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

Add comma after '7px' and: 在“ 7px”之后添加逗号,然后:

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

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

Replace: 更换:

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

With: 带有:

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

i have try with a simple trick.. 我尝试了一个简单的技巧。

first add a class to scroll bar, by default it is 'slimScrollBar' 首先将一个类添加到滚动条,默认情况下为“ slimScrollBar”

barClass : 'slimScrollBar_new' barClass:'slimScrollBar_new'

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM