试试这个在IE和Safari和FF上使用和测试非常简单,并且工作良好,旁边不需要很多div
只需加上id
,它会在您连接Js和Css文件后正常工作。 FaceScroll Custom scrollbar
希望它帮助的
编辑 第1步:下面的脚本添加到您的网页的部分:
<link href="general.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="facescroll.js"></script>
<script type="text/javascript">
jQuery(function(){ // on page DOM load
$('#demo1').alternateScroll();
$('#demo2').alternateScroll({ 'vertical-bar-class': 'styled-v-bar', 'hide-bars': false });
})
</script>
第2步:然后在你的页面的正文中,添加在示例HTML块下面到您的页面。
<p><b>Scrollbar (default style) shows onMouseover</b></p>
<div id="demo1" style="width:300px; height:250px; padding:8px; background:lightyellow; border:1px solid gray; resize:both; overflow:scroll">
From Wikipedia- Gunpowder, also known since in the late 19th century as black powder, was the first chemical explosive and the only one known until the mid 1800s.[2] It is a mixture of sulfur, charcoal, and potassium nitrate (saltpeter) - with the sulfur and charcoal acting as fuels, while the saltpeter works as an oxidizer.[3] Because of its
</div>
<br />
<p><b>Scrollbar (alternate style), always shown</b></p>
<div id="demo2" style="width:400px; height:130px; padding:10px; padding-right:8px; background:lightyellow; border:1px solid gray; overflow:scroll; resize:both;">
From Wikipedia- Gunpowder, also known since in the late 19th century as black powder, was the first chemical explosive and the only one known until the mid 1800s.[2] It is a mixture of sulfur, charcoal, and potassium nitrate (saltpeter) - with the sulfur and charcoal acting as fuels, while the saltpeter works as an oxidizer.[3] Because of its
</div>
对于WebKit浏览器(Chrome/Safari),您可以使用以下代码:http://stackoverflow.com/questions/7713599/styling-an-inner-scrollbar-like-the-twitter -conversation-interface/7713784#7713784 – thirtydot
@graphicdivine,只有当他们改变整个主体的滚动条时才会出现这种情况。还有很多其他滚动条可以修改(在网页内),它与浏览器镶边无关。 – Dan
此链接显示您必须在Webkit浏览器上执行此操作:http://css-tricks.com/custom-scrollbars-in-webkit/ – user1108509