Questions tagged [scrollbar]

A scrollbar is a graphical user interface element relating to a display which is only partially visible. The scroll bar provides visual feedback on which portion of the element is in view, and the ability to move the view of the main element.

Scrollbars are present in a wide range of electronic devices including computers, graphing calculators, mobile phones, and portable media players. Scrollbars are usually displayed one or two sides of the viewing area, containing a bar, that can be dragged along a trough (or track) to move the body of the document as well as two arrows on either end for precise adjustments.

Even though scrollbars and sliders work in similar fashion, their difference is that slider changes values, while scrollbar moves the area that is currently shown.

A simple example of SO editing textareas scrollbar:

SO Tag Wiki editing textarea scrollbar


2. Vendor Specific Values

2.1 Internet Explorer 5.5+

html{
    scrollbar-face-color:#ffffff;
    scrollbar-arrow-color:#ffffff;
    scrollbar-track-color:#ffffff;
    scrollbar-shadow-color:#ffffff;
    scrollbar-highlight-color:#ffffff;
    scrollbar-3dlight-color:#ffffff;
    scrollbar-darkshadow-color:#ffffff;
}

2.2 Webkit

::-webkit-scrollbar{
    width:#px;
    height:#px;
}
::-webkit-scrollbar-track{
    background:#ffffff;
}
::-webkit-scrollbar-thumb{
    background:#ffffff;
}

2.3 Gecko (MOZ)

It's worth noting that the attribute which controls whether or not scrollbars are displayed in Firefox is: (reference link)

Attribute: scrollbars Type: nsIDOMBarProp Description: The object that controls whether or not scrollbars are shown in the window. This attribute is "replaceable" in JavaScript. Read only

overflow: -moz-scrollbars-none

other valid values are -moz-scrollbars-horizontal and -moz-scrollbars-vertical.

5831 questions
785
votes
21 answers

Hiding the scroll bar on an HTML page

Can CSS be used to hide the scroll bar? How would you do this?
ANP
  • 13,969
  • 21
  • 53
  • 78
565
votes
17 answers

Make iframe automatically adjust height according to the contents without using scrollbar?

For example: I want it to be able to adjust its height according to the contents inside it, without using scroll.
akashbc
  • 5,665
  • 3
  • 12
  • 4
357
votes
10 answers

Automatic vertical scroll bar in WPF TextBlock?

I have a TextBlock in WPF. I write many lines to it, far exceeding its vertical height. I expected a vertical scroll bar to appear automatically when that happens, but it didn't. I tried to look for a scroll bar property in the Properties pane, but…
Bab Yogoo
  • 5,949
  • 6
  • 19
  • 16
352
votes
10 answers

Custom CSS Scrollbar for Firefox

I want to customize a scrollbar with CSS. I use this WebKit CSS code, which works well for Safari and Chrome: ::-webkit-scrollbar { width: 15px; height: 15px; } ::-webkit-scrollbar-track-piece { background-color:…
Dimitri Vorontzov
  • 6,686
  • 10
  • 44
  • 75
344
votes
20 answers

CSS customized scroll bar in div

How can I customize a scroll bar via CSS (Cascading Style Sheets) for one div and not the whole page?
harisdev
  • 3,876
  • 5
  • 16
  • 23
302
votes
19 answers

How can I check if a scrollbar is visible?

Is it possible to check the overflow:auto of a div? For example: HTML
* content
JQUERY $('.my_class').live('hover', function (event) { if…
Peter
  • 9,629
  • 29
  • 90
  • 143
282
votes
8 answers

Hide html horizontal but not vertical scrollbar

I have an HTML textarea that is of fixed width, but variable height. I would like to set overflow:scroll and be able to show a vertical scrollbar, but not a horizontal one. I am not able to use overflow:auto due to other things specific to my…
William Jones
  • 17,349
  • 16
  • 57
  • 97
184
votes
6 answers

How can I prevent the scrollbar overlaying content in IE10?

In IE10, the scrollbar is not always there... and when it appears it comes on as an overlay... It's a cool feature but I would like to turn it off for my specific website as it is a full screen application and my logos and menus are lost behind…
Jimmyt1988
  • 18,656
  • 34
  • 113
  • 210
181
votes
6 answers

How do I make the scrollbar on a div only visible when necessary?

I have this div:
here is some text
The scrollbars are always visible, even though the text does not overflow. I want to make the scrollbars only be visible when necessary - that is, only…
Benubird
  • 15,843
  • 24
  • 83
  • 128
169
votes
23 answers

How can I get the browser's scrollbar sizes?

How can I determine the height of a horizontal scrollbar, or the width of a vertical one, in JavaScript?
glmxndr
  • 42,138
  • 27
  • 90
  • 115
169
votes
5 answers

Preventing scroll bars from being hidden for MacOS trackpad users in WebKit/Blink

WebKit/Blink's (Safari/Chrome) default behaviour on MacOS since 10.7 (Mac OS X Lion) is to hide scroll bars from trackpad users when they're not in use. This can be confusing; the scroll bar is often the only visual cue that an element is…
Jeremy
  • 1
  • 77
  • 324
  • 346
168
votes
6 answers

CSS scrollbar style cross browser

How can I define a CSS scrollbar style cross browser? I tested this code, it only works in IE and opera, but failed in Chrome, Safari and Firefox.