Teman-teman WebHozz kali ini kita akan mencoba sebuah tutorial, yaitu merubah tampilan scroll bar dengan jquery. Biasanya tampilan scroll bar terlihat begitu kaku atau tampilannya hanya begitu-begitu saja pada sebuah jendela browser. Nah untuk itulah kali ini kita akan mencoba memberikan efek dengan bantuan jQuery. Oke sudah siap.
Buat file html seperti berikut ini :
<body> <div class="content"> <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p> </div><!--end of content--> </body>
Sedikit kita berikan jenis font supaya tampil beda, seperti ini:
<style> @import url(http://fonts.googleapis.com/css?family=Open+Sans); .content{ width: 500px; height: 200px; margin: auto; border: solid 1px; overflow-y: scroll; } p{ font-family: 'Open Sans', sans-serif; } </style>
Dan yang paling penting teman-teman WebHozz jangan lupa meletakkan script jQuery, seperti berikut ini :
<script type="text/javascript" src="jquery-1.11.2_min.js"></script> <script type="text/javascript" src="jquery.nicescroll-master/jquery.nicescroll.min.js"></script> <script> $(document).ready(function() { var nice = $(".content").niceScroll(); // The document page (body) //tambahan silahkan di edit--> //$("html").niceScroll({cursoropacitymin:1,cursorcolor:"#808080",cursorborder:"1px solid #565656",background:"#ddd"}); }); </script>
Nah teman-teman mudah bukan, silahkan di eksplor lagi ya,…