Adam Buchanan Smith
Adam Buchanan Smith

Reputation: 9439

Set the length of a horizontal scrollbar

It would seem that this would be a duplicate question, however I cannot find anything on it.

I am trying to set the length of a scrollbar to 50% of the <div>

I am using webkit to hide the actual scrollbar and show and image instead, however the thumb of the scrollbar goes outside the slidebar img itself. So if i can shorten the scrollbar length it would solve all my issues.

Ideally I would like a webkit fix but am open to other ideas.

currently i have this for the css:

::-webkit-scrollbar-button:start:decrement,
    ::-webkit-scrollbar-button:end:increment  {}
    ::-webkit-scrollbar-thumb:horizontal {
            background:transparent url('images/sliderheart.png') no-repeat; 
            background-size:35px 35px;

            width: 35px;
            height: 35px;  
            background-position: center;
    }
    ::-webkit-scrollbar{height: 50px; width: 50px;}


    ::-webkit-scrollbar-track:horizontal{
    background:transparent url('images/sliderbar.png') no-repeat; 
    background-position: center; 
    }

Upvotes: 1

Views: 3319

Answers (2)

Adam Buchanan Smith
Adam Buchanan Smith

Reputation: 9439

So I figured it out and should share in-case someone else comes across the same issue.

I was barking up the wrong tree, instead of changing the actual scroll bar, I found this solution.

Make a start and stop position of the thumb like this:

::-webkit-scrollbar-button:end{height: 50px; width:30%;}
::-webkit-scrollbar-button:start{height: 50px; width:30%;}

Then size the background image to fit inside the start and end like this:

::-webkit-scrollbar-track:horizontal{
    background:transparent url('images/sliderbar.png') no-repeat; 
    background-position: center;
    background-size: 100% 35px; 
    }

Upvotes: 1

Ikbel
Ikbel

Reputation: 7851

Try this:

::-webkit-scrollbar{height: 50%; width: 50%;}

Upvotes: 0

Related Questions