2017-06-02 46 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; 
    }