One issue I always encounter in web designing is when I need to re-style the default ugly scroll bars produced when you have a div that is overflowing.

Though you can actually edit the style of it via CSS, you may still worry if this will be applied on other browsers.

So for this problem, I usually prefer to use a script that change the style dynamically on load. Though, not all users enable their scripts, we can't deny that compared to those enabled ones, their amount is minimal.
Anyway, here is a plugin in JQuery that I found over the net -- Enscroll

I chose Enscroll among others since it is easy to set-up. Using it is just as simple as applying a CSS and binding the your div element to an event handler.

Here is a quick sample of how it is used:

HTML

  1. <div id="scrollbox3">
  2. <p>
  3. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam a justo erat, volutpat hendrerit dolor.
  4. Sed urna nibh, dapibus at egestas non, vulputate ut quam.
  5. Morbi a erat tristique tellus varius venenatis. Aenean lacinia sem eget turpis fringilla commodo.
  6. Sed lorem nisi, viverra a interdum nec, varius eu enim.
  7. Donec ornare, nunc quis eleifend iaculis, nulla eros mollis tellus, quis faucibus risus odio non lectus.
  8. Maecenas ac velit non metus rhoncus commodo. Nunc ligula est, ultricies sed mattis sed, dapibus at arcu.
  9. Maecenas lacinia nisl ut sem bibendum ac condimentum purus facilisis.
  10. Curabitur ut nibh lobortis libero interdum vehicula vel quis nulla.
  11. </p>
  12. </div>

JQuery

  1. $('#scrollbox3').enscroll({
  2. showOnHover: true,
  3. clickTrackToScroll: false,
  4. verticalTrackClass: 'track3',
  5. verticalHandleClass: 'handle3'
  6. });

CSS

  1. #scrollbox3 {
  2. overflow: auto;
  3. width: 400px;
  4. height: 360px;
  5. padding: 0 5px;
  6. border: 1px solid #b7b7b7;
  7. }
  8.  
  9. .track3 {
  10. width: 10px;
  11. }
  12.  
  13. .handle3 {
  14. width: 5px;
  15. background: #000;
  16. opacity: 0.45;
  17. filter: alpha(opacity=45);
  18. border: 1px solid #555;
  19. -webkit-border-radius: 7px;
  20. -moz-border-radius: 7px;
  21. border-radius: 7px;
  22. }

Here is a demo of the said scroll bar:


No comments :

Post a Comment