Speed up development with full-stack environments for every branch.

Learn More

How to make an Element Scrollable with jQuery [perfect-scrollbar]

Forked from How to use the jQuery UI Slider.

316 Runs 808 Views 233 Copies
Saved

Saved

pg1 45

pg1
published 4 years ago

<!doctype html>
<html>
<head>

    <title>How to make an Element Scrollable with jQuery</title>
    
    <style>
        body{
            text-align: center;
            font-family: arial;
        }
   
        #scrollview{
            width:400px;
            margin:20px auto;
            text-align: left;
            height:200px;
            overflow: hidden;
            position: relative;
        }

        #scrollview .content{
            position: absolute;
            padding-right:20px; 
        }
        
    </style>


</head>
<body>

    <div id="scrollview">
        <div class="content">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
        </div>
    </div>
   
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    
    <!-- plugin stylesheet and js lib -->
    <link href="perfect-scrollbar-0.4.3.min.css" rel="stylesheet">
    <script src="perfect-scrollbar-0.4.3.with-mousewheel.min.js"></script>

    <script>

        //When DOM loaded we add the scroll to element
        $(document).ready(function() {

            //perfectScrollbar plugin is used. 
            //You can get latest version from here: http://www.yuiazu.net/perfect-scrollbar/
            $('#scrollview').perfectScrollbar();

        });

    </script>

</body>
</html>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).