JQuery Scrollable Text

前端 未结 3 1818
旧巷少年郎
旧巷少年郎 2021-01-28 09:47

I\'m searching for a jquery plugin that will bound text inside a scrollable box. Most of the scroll plugins are converting the browser scroll bar but I want to keep that as it i

相关标签:
3条回答
  • 2021-01-28 09:56

    If you need to dynamically do this to elements, just wrap the content in a <div> with a special class:

    CSS:

    .scroll {
        overflow: auto;
        max-height: 100px;
    }
    

    JS:

    $(document).ready(function() {
        $('.elements_that_should_scroll').wrap($('<div>', {'class': 'scroll'}));
    });
    

    Demo: http://jsfiddle.net/nW7uH/

    If not, just give those elements the class scroll and it should work just fine without JS.

    0 讨论(0)
  • 2021-01-28 10:02

    You really don't need jQuery for this. Just some CSS.

    .Information{
    height:100px;
    overflow:auto;
    }
    

    If you have a genuine need for this plugin then make sure you're referencing jQuery correctly and the link to the plugin js file.

    If you run the page in your browser do you get anything in the console window. Any errors.

    EDIT: Added a JSFiddle

    EDIT: Also be sure you're referencing the required assets:

    jquery.uscrollbar.js
    jquery.uscrollbar.css
    
    0 讨论(0)
  • 2021-01-28 10:11

    Make sure you specify a fixed width and height for your container div, in your case, the div with the class Information. Add this to your CSS file.

    .Information {
        height: 300px;
        width: 300px;
    }
    
    0 讨论(0)
提交回复
热议问题