Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help styling jScrollPane

I am trying to style my jScrollPane

but I find that my scroll bar is extending out of the container

How can I fix it? Code can be seen in http://jsfiddle.net/Mfest/

like image 253
Jiew Meng Avatar asked Mar 28 '26 19:03

Jiew Meng


2 Answers

The recommended solution is to use the .jspCap to add space above or below the track rather than padding or borders. I've implemented this here:

http://jsfiddle.net/Mfest/6/

Note that I set the top and bottom caps to different sizes to make things appear to line up equally - I think that the rounded corners/ borders may be confusing the jScrollPane calculations a little bit.

Another demo of the caps in action: http://jscrollpane.kelvinluck.com/caps.html

like image 72
vitch Avatar answered Mar 31 '26 09:03

vitch


My answer is now redundant, see the below answer.


I don't know the "proper jScrollPane method", but this does work in modern browsers.

The problem is that the padding and border on .jspTrack is adding up to make the height of the scrollbar 306px, instead of 300px.

So, you can use the box-sizing property on .jspTrack:

    /* https://developer.mozilla.org/en/CSS/box-sizing */
    width: 12px; /* adjust width */
    /* support Firefox, Safari/WebKit, Opera and IE8 */
   -moz-box-sizing:    border-box;
   -webkit-box-sizing: border-box;
    box-sizing:        border-box;

See: http://jsfiddle.net/Mfest/2/

I would personally not be satisfied with this answer, because it seems a kludgy way to fix it.

like image 36
thirtydot Avatar answered Mar 31 '26 09:03

thirtydot