【发布时间】:2013-01-10 09:49:17
【问题描述】:
你能帮帮我吗,如何使用 CSS 设计垂直滚动条...有没有办法使用 css 或 css3 自定义垂直滚动条设计...提前谢谢..
【问题讨论】:
-
滚动条很难设计。所以我使用 JScrollPane。 jscrollpane.kelvinluck.com
-
你能分享你的代码来解释你想在哪里自定义你的滚动条
你能帮帮我吗,如何使用 CSS 设计垂直滚动条...有没有办法使用 css 或 css3 自定义垂直滚动条设计...提前谢谢..
【问题讨论】:
看看this 网站。它为基于-webkit- 的浏览器使用定制的滚动条。当您检查 css 文件时,很清楚使用的是什么 css。
@media only screen and (-webkit-min-device-pixel-ratio: 0) and (min-device-width: 1025px) {
html { overflow: hidden; }
body {
position: absolute;
bottom: 0;
left: 0;
right: 12px;
top: 0;
overflow-y: auto;
overflow-x: hidden;
}
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-button:start:decrement,
::-webkit-scrollbar-button:end:increment {
display: block;
height: 10px;
}
::-webkit-scrollbar-button:vertical:increment {
background-color: #fff;
}
::-webkit-scrollbar-track-piece {
background-color: #eee;
-webkit-border-radius: 3px;
}
::-webkit-scrollbar-thumb:vertical {
height: 50px;
background-color: #ccc;
-webkit-border-radius: 3px;
}
::-webkit-scrollbar-thumb:horizontal {
width: 50px;
background-color: #ccc;
-webkit-border-radius: 3px;
}
不过,http://jscrollpane.kelvinluck.com/ 是迄今为止我使用过的跨浏览器滚动条定制器的最佳示例......
【讨论】:
webkit 的浏览器,即 Chrome 和 Safari。如果你想在 Firefox 中使用基于gecko 的自定义滚动条,我建议使用jscrollpane.kelvinluck.com
.scrollbar{ position: absolute; top: 20px; left: 85px; width: 499px;
overflow-y: scroll;
overflow-x: hidden;
padding-right: 5px;
visibility: visible;
border: thin solid white;
background-color: #336699;
scrollbar-face-color: #336699; scrollbar-3dlight-color: #336699; scrollbar-base-color: #336699;
scrollbar-track-color: #336699; scrollbar-darkshadow-color: #000; scrollbar-arrow-color: #000;
scrollbar-shadow-color: #fff; scrollbar-highlight-color: #fff; }
【讨论】:
使用这个
.scroll
{
display: block;
border: 1px solid gray;
padding: 10px 0px 0px 0px;
margin-top: 5px;
width: 212px;
height: 320px;
overflow-y: scroll;
background-color: white;
margin-left: 15px;
}
【讨论】: