basic.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link href="../css/perfect-scrollbar.css" rel="stylesheet">
  5. <script src="../dist/perfect-scrollbar.js"></script>
  6. <style>
  7. #container {
  8. position: relative;
  9. margin: 0px auto;
  10. padding: 0px;
  11. width: 600px;
  12. height: 400px;
  13. overflow: auto;
  14. }
  15. #container .content {
  16. background-image: url('./assets/azusa.jpg');
  17. width: 1280px;
  18. height: 720px;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div id="container">
  24. <div class="content">
  25. </div>
  26. </div>
  27. <p style='text-align: center'>
  28. Width <input type='text' id='width' value='600'>
  29. Height <input type='text' id='height' value='400'>
  30. <button onclick='updateSize()'>Change!</button>
  31. </p>
  32. <script>
  33. var $ = document.querySelector.bind(document);
  34. var ps = new PerfectScrollbar('#container');
  35. function updateSize() {
  36. var width = parseInt($('#width').value, 10);
  37. var height = parseInt($('#height').value, 10);
  38. $('#container').style.width = width + 'px';
  39. $('#container').style.height = height + 'px';
  40. ps.update();
  41. }
  42. </script>
  43. </body>
  44. </html>