試試這個在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