2017-06-02 97 views
0

我的風格我的垂直滾動條與下面的代碼:如何通過CSS設置水平滾動條的樣式?

::-webkit-scrollbar { 
    width: 4px; 
    border: 1px solid #d5d5d5; 
} 

::-webkit-scrollbar-track { 
    border-radius: 0; 
    background: #eeeeee; 
} 

::-webkit-scrollbar-thumb { 
    border-radius: 0; 
    background: #b0b0b0; 
} 

現在,我的垂直滾動條是這樣的:

enter image description here

然而,我的水平滾動條是這樣的:

enter image description here

如何設置2-4px高度f或者它?

+0

根據[這篇文章](https://css-tricks.com/custom-scrollbars-in-webkit/)有一個':horizo​​ntal'僞類... –

回答

1
::-webkit-scrollbar { 
    height: 4px;    /* you're missing height! */ 
    width: 4px; 
    border: 1px solid #d5d5d5; 
} 

,因爲你不能在邏輯上強制滾動條在一定高度,在height屬性用於設置水平的滾動條高度:)

0

這可能有助於

::-webkit-scrollbar{ 
     height: 4px; 
     width: 4px; 
     background: gray; 
    } 
    ::-webkit-scrollbar-thumb:horizontal{ 
     background: #000; 
     border-radius: 10px; 
    }