Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS show horizontal scroll bars?

Tags:

html

css

I saw this stackoverflow post CSS div element - how to show horizontal scroll bars only? However when I try the answers the scroll bar is not shown. I can scroll horizontally, but I also want the horizontal scroll bar to be shown. I am trying this on chrome and Mac. Here is my code:

<div style="width:500px; overflow-x:scroll; border:dotted 1px; white-space: nowrap;padding-bottom:10px;">
<img src="img1.jpeg">
<img src="img2.jpeg">
<img src="img3.jpeg">
<img src="img4.jpeg">
<img src="img5.jpeg">
</div>

JsFiddle: https://jsfiddle.net/t30xshro/

like image 484
apadana Avatar asked Dec 08 '22 02:12

apadana


1 Answers

As stated in the comments, OSX hides scrollbars by default.

There are a few CSS options which explicitly work for osX/Chrome in order to handle ScrollBar behaviour/appearance:

.frame::-webkit-scrollbar {
    -webkit-appearance: none;
}

.frame::-webkit-scrollbar:horizontal {
    height: 11px;
}

.frame::-webkit-scrollbar-thumb {
    border-radius: 8px;
    border: 2px solid white;
    background-color: rgba(0, 0, 0, .5);
}
.frame::-webkit-scrollbar-track { 
    background-color: #fff; 
    border-radius: 8px; 
}

JsFiddle: https://jsfiddle.net/peanut/zvskLcef/

like image 126
Peanut Avatar answered Dec 23 '22 23:12

Peanut