16

Side panel scrollbar

The scroll bar can be seen in the side-panel when you click on a tweet and the conversation linked to the tweet is long enough.

How is the scroll bar created and styled?

brenjt
  • 15,997
  • 13
  • 77
  • 118
Mattis
  • 5,026
  • 3
  • 34
  • 51

2 Answers2

35

They're using ::-webkit-scrollbar and the associated pseudo-elements, which only work in WebKit browsers (which is fine, because this is just aesthetics).

Take a look at this for more information: Apple-like scrollbars using CSS

I've taken the CSS that Twitter is using, see: http://jsbin.com/ubasew

#doc ::-webkit-scrollbar{width:9px;height:9px;}
#doc ::-webkit-scrollbar-button:start:decrement,#doc ::-webkit-scrollbar-button:end:increment{display:block;height:0;background-color:transparent;}
#doc ::-webkit-scrollbar-track-piece{background-color:#FAFAFA;-webkit-border-radius:0;-webkit-border-bottom-right-radius:8px;-webkit-border-bottom-left-radius:8px;}
#doc ::-webkit-scrollbar-thumb:vertical{height:50px;background-color:#999;-webkit-border-radius:8px;}
#doc ::-webkit-scrollbar-thumb:horizontal{width:50px;background-color:#999;-webkit-border-radius:8px;}

The #doc is as Twitter had it, and it's there so that only scrollbars inside #doc are customised.

Community
  • 1
  • 1
thirtydot
  • 224,678
  • 48
  • 389
  • 349
  • 3
    I bow my head in the radiance of your glorious anwering-skills :) – Mattis Oct 10 '11 at 14:29
  • 3
    Note that this removes the up and down arrows, and ignores the user's scrollbar width settings. It might be pretty, but it's bad for usability. It's acceptable for a small iframe or scrollable div, but I wouldn't use it on a whole page. If you do, at least make the scrollbar look like a scrollbar. If the gutter color matches the page background, the user may get to the end of the visible area and not even realize there's a scrollbar because the button is way up above. – Webveloper May 30 '12 at 18:15
  • is that webkit only ? – zx1986 Aug 17 '14 at 03:26
  • 1
    @Webveloper .. up and down arrows are so old school – quemeful Jun 23 '15 at 21:49
  • This does not work for me, tested on latest Firefox and Chrome, for some reason it does not render the code :( – The Bumpaster Jul 09 '15 at 09:14
9

I believe they are using a jQuery plugin or one created by themselves, either way it's something similar to jScrollPane

http://www.kelvinluck.com/assets/jquery/jScrollPane/jScrollPane.html

no.
  • 2,356
  • 3
  • 27
  • 42