无法使用CSS将宽度和高度应用于-webkit-scrollbar [英] Can't apply width and height to -webkit-scrollbar using CSS

查看:780
本文介绍了无法使用CSS将宽度和高度应用于-webkit-scrollbar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-thumb {
    background-color:#808080;
}

为什么width和height属性不起作用?

Why do the width and height attributes not work?

推荐答案

width用于垂直滚动条,而height影响水平滚动条.您不能为垂直滚动条定义高度.那取决于内容的大小.

width is for vertical scrollbars and height affects horizontal scrollbars. You can't define height for a vertical scrollbar. That is dependent on content size.

如果要将背景图像添加到滚动条,则将它们添加为普通元素:

If you want to add background images to your scrollbar, they are added like normal elements:

::-webkit-scrollbar {
    width: 50px;
    height: 50px;
    background:-webkit-linear-gradient(0, blue 50%, white 100%);

}

::-webkit-scrollbar-thumb {
    background-color:#808080;
        background:url("http://www.topdesignmag.com/wp-content/uploads/2010/12/137.jpg");
}

小提琴

这篇关于无法使用CSS将宽度和高度应用于-webkit-scrollbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆