通过假设您要自定义浏览器的滚动条,
你可以用一些不错的jQuery插件很容易地做到这一点,或者你可以用CSS做的魔力。但它只能在WebKit浏览器,现在,这里是如何
::-webkit-scrollbar {
width: 12px;
}
/* Track */
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
-webkit-border-radius: 10px;
border-radius: 10px;
}
/* Handle */
::-webkit-scrollbar-thumb {
-webkit-border-radius: 10px;
border-radius: 10px;
background: rgba(255,0,0,0.8);
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
background: rgba(255,0,0,0.4);
}
来源:http://css-tricks.com/custom-scrollbars-in-webkit/
否则,您可以使用插件。 (推荐)
正如在早期的评论,我建议你使用niceScroller插件。这很好,很容易。
来源:http://areaaperta.com/nicescroll/
简单实现
<script>
$(document).ready(
function() {
$("html").niceScroll();
}
);
</script>
如果我理解正确,你试图获得一个自定义滚动条,它仍然能够滚动页面,对不对?如果是这样,我推荐https://github.com/inuyaksa/jquery.nicescroll它是非常可定制的,并且也可以在移动设备上运行。 – 2013-07-20 04:18:17
可能的解决方案在这里:http://stackoverflow.com/questions/9251354/css-customized-scroll-bar-in-div – 2013-07-20 04:19:40
你也可以试试这个:http://manos.malihu.gr/tuts/custom- scrollbar-plugin/complete_examples.html – Miro