Need help styling jScrollPane
I am trying to style my jScrollPan开发者_运维问答e
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/
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
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.
you have padding:2px;
for .jspTrack
this add padding for top and bottom of scrollbar, with result to overflow the container. Try to change it to padding:0 2px;
.
Update: I set fixed heights for .jspTrack
and .jspDrag
also.
Demo: http://jsfiddle.net/Mfest/3/
精彩评论