2011-10-10 52 views

回答

35

他們使用::-webkit-scrollbar和相關的僞元素,其中只有工作在WebKit瀏覽器中(這很好,因爲這只是美學)。

在此看一看以瞭解更多信息:Apple-like scrollbars using CSS

我已經採取了Twitter的使用CSS,請參見: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;} 

#doc是如Twitter有它,和它的存在這樣只有#doc內的滾動條才能定製。

+3

我低頭你的輝煌anwering-技能的光芒:) – Mattis

+3

請注意,這將刪除up向下箭頭,並忽略用戶的滾動條寬度設置。這可能很漂亮,但這對可用性很糟糕。對於一個小的iframe或可滾動的div是可以接受的,但我不會在整個頁面上使用它。如果你這樣做,至少使滾動條看起來像一個滾動條。如果陰溝顏色與頁面背景相匹配,用戶可能會到達可見區域的末端,甚至沒有意識到存在滾動條,因爲按鈕位於上方。 – Webveloper

+0

是隻有webkit? – zx1986