javascript - How to change the color of scrollbar? - Stack Overflow

I want to change the color of the scroll bar.For creating the scroll bar I used the given code.javascr

I want to change the color of the scroll bar.For creating the scroll bar I used the given code.
javascript is

$('.scroll-pane').jScrollPane();


    $('#body').bind(
    'jsp-scroll-y',
    function (event, scrollPositionY, isAtTop, isAtBottom) {
        console.log('#pane1 Handle jsp-scroll-y', this,
                        'scrollPositionY=', scrollPositionY,
                        'isAtTop=', isAtTop,
                        'isAtBottom=', isAtBottom);
    }
);

css is

.scroll-pane
{
    width: 100%;
    height: 300px;
    overflow: auto;
}

But here I cannot change the color of the scroll bar.How can I change the color? Demo

I want to change the color of the scroll bar.For creating the scroll bar I used the given code.
javascript is

$('.scroll-pane').jScrollPane();


    $('#body').bind(
    'jsp-scroll-y',
    function (event, scrollPositionY, isAtTop, isAtBottom) {
        console.log('#pane1 Handle jsp-scroll-y', this,
                        'scrollPositionY=', scrollPositionY,
                        'isAtTop=', isAtTop,
                        'isAtBottom=', isAtBottom);
    }
);

css is

.scroll-pane
{
    width: 100%;
    height: 300px;
    overflow: auto;
}

But here I cannot change the color of the scroll bar.How can I change the color? Demo

Share Improve this question edited Apr 9, 2013 at 13:01 Nithin Viswanathan asked Apr 9, 2013 at 11:44 Nithin ViswanathanNithin Viswanathan 3,2837 gold badges45 silver badges85 bronze badges 0
Add a ment  | 

5 Answers 5

Reset to default 4

These two elements are basically the scroll bar and drag handler.

.jspTrack {
    background: lightgray !important;
}

.jspDrag {
    background: gray !important;
}

Edit: really making sure the colors get applied.

You can stylize drag element .jspDrag:

.jspDrag {
    background-color: #000;
}

and the scollbar .jspVerticalBar itself:

.jspVerticalBar {
    background-color: rgba(0,0,0,0.5);
}

UPD Working example http://jsfiddle/KVyAG/2/

This may help you. For particular class or id you can just write name of class or id instead of BODY

 <style type="text/css">
    BODY{
    scrollbar-face-color:#DFFFBF;
    scrollbar-shadow-color:green;
    }
    </style>

You can also use following property:

  • 1) scrollbar-3dlight-color 2) scrollbar-arrow-color 3) scrollbar-base-color 4) scrollbar-darkshadow-color 5) scrollbar-face-color 6) scrollbar-highlight-color 7) scrollbar-shadow-color 8) scrollbar-track-color

Try this:

.scroll-pane
 {
 width: 100%;
  height: 300px;
  overflow: auto;
  background-color:#000000;
}

We can change color of scrollbar using javascript also. There are various ponents in scroll bar like base color, face color, arrow color etc that changes color of various parts of scroll bar. The following lines might help you.

document.body.style.scrollbarBaseColor = "colorname";
document.body.style.scrollbarArrowColor = "colorname";
document.body.style.scrollbarTrackColor = "colorname";

Apart from the above styles, you will have scrollbarShadowColor, scrollbarHighlightColor, scrollbar3dlightColor,scrollbarDarkshadowColor etc. So, choose your ponent of scroll bar and change the color of it.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745544703a4632287.html

相关推荐

  • javascript - How to change the color of scrollbar? - Stack Overflow

    I want to change the color of the scroll bar.For creating the scroll bar I used the given code.javascr

    22小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信