css设置滚动条宽度设置

html-css013

css设置滚动条宽度设置,第1张

/* 设置滚动条的样式 */

::-webkit-scrollbar {

width:12px

}

/* 滚动槽 */

::-webkit-scrollbar-track {

-webkit-box-shadow:inset006pxrgba(0,0,0,0.3)

border-radius:10px

}

/* 滚动条滑块 */

::-webkit-scrollbar-thumb {

border-radius:10px

background:rgba(0,0,0,0.1)

-webkit-box-shadow:inset006pxrgba(0,0,0,0.5)

}

::-webkit-scrollbar-thumb:window-inactive {

background:rgba(255,0,0,0.4)}

改变浏览器默认的滚动条样式:

//滚动条凹槽的颜色,还可以设置边框属性

::-webkit-scrollbar-track-piece{

background-color:#f8f8f8 

}

//滚动条的宽度

::-webkit-scrollbar{

width:9px

height:9px

}

//滚动条的设置

::-webkit-scrollbar-thumb{

background-color:#dddddd

background-clip:padding-box

min-height:28px

}

::-webkit-scrollbar-thumb:hover{

background-color:#bbb

}

扩展资料:

给某个div,class为test1加滚动条样式:

.test1::-webkit-scrollbar{

width:8px

}

.test1::-webkit-scrollbar-track{

background-color:red

-webkit-border-radius:2em

-moz-border-radius:2em

border-radius:2em

}

.test1::-webkit-scrollbar-thumb{

background-color:green

-webkit-border-radius:2em

-moz-border-radius:2em

border-radius:2em

}