【发布时间】:2021-01-26 02:53:48
【问题描述】:
谁能告诉我如何调整滚动条拇指的高度?
我尝试了很多不同的东西,比如
::-webkit-scrollbar-thumb {
height: 10px;
}
::-webkit-scrollbar-thumb {
max-height: 200px;
}
::-webkit-scrollbar-thumb {
margin-top: 10px;
margin-bottom: 10px;
}
我也读过这个答案Change scrollbar height 和How to change the height of a scrollbar thumb?,但它没有用。有人回答说不能改变滚动条拇指的高度那么这个网站https://css-tricks.com/custom-scrollbars-in-webkit/是怎么做到的?
我当前的代码是
body {
height: 110vh;
}
::-webkit-scrollbar {
width: 1rem;
}
::-webkit-scrollbar-track {
background: rgb(24, 24, 24);
}
::-webkit-scrollbar-thumb {
background-color: #3EECAC;
background-image: linear-gradient(19deg, #3EECAC 0%, #EE74E1 100%);
border-radius: 1rem;
}
【问题讨论】:
-
在垂直滚动中你不能设置高度,同样你不能在水平滚动中设置宽度。
-
你在火狐上吗? (我是)它在 Firefox 上不起作用:developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar(或 Internet Explorer)
-
试试去这个网站:stackoverflow.com/questions/50817727/change-scrollbar-height看答案,第二个有红色滚动条吗?如果不是,则您的浏览器不支持。
-
不,我使用的是谷歌浏览器