gromo / jquery.scrollbar

jQuery CSS Customizable Scrollbar
GNU General Public License v2.0
755 stars 237 forks source link

Have copied your examples - not working #129

Closed clarkk closed 7 years ago

clarkk commented 7 years ago

I have copied the examples from https://gromo.github.io/jquery.scrollbar/demo/basic.html but they are not working. What am I missing? I just copied it as it is

https://jsfiddle.net/kk1sy7ve/2/

Have two examples:

<h1>Simple outer (content height)</h1>
<div class="scrollbar-outer" style="height:100px">
    <p>
        Simple outer scrollbar can be used as CSS base for custom outer scrollbars.
        This example shows nested scrollbars functionality: nested scrollbar styles do not
        interfere with parent scrollbar styles, i.e. different scrollbars can be safely used
        inside each other.
    </p>
    <p>
        Simple outer scrollbar can be used as CSS base for custom outer scrollbars.
        This example shows nested scrollbars functionality: nested scrollbar styles do not
        interfere with parent scrollbar styles, i.e. different scrollbars can be safely used
        inside each other.
    </p>
    <p>
        Simple outer scrollbar can be used as CSS base for custom outer scrollbars.
        This example shows nested scrollbars functionality: nested scrollbar styles do not
        interfere with parent scrollbar styles, i.e. different scrollbars can be safely used
        inside each other.
    </p>
</div>

<h1>Simple outer (container max-height)</h1>
<div style="max-height:100px">
    <div class="scrollbar-outer">
        <p>
            Simple outer scrollbar can be used as CSS base for custom outer scrollbars.
            This example shows nested scrollbars functionality: nested scrollbar styles do not
            interfere with parent scrollbar styles, i.e. different scrollbars can be safely used
            inside each other.
        </p>
        <p>
            Simple outer scrollbar can be used as CSS base for custom outer scrollbars.
            This example shows nested scrollbars functionality: nested scrollbar styles do not
            interfere with parent scrollbar styles, i.e. different scrollbars can be safely used
            inside each other.
        </p>
        <p>
            Simple outer scrollbar can be used as CSS base for custom outer scrollbars.
            This example shows nested scrollbars functionality: nested scrollbar styles do not
            interfere with parent scrollbar styles, i.e. different scrollbars can be safely used
            inside each other.
        </p>
    </div>
</div>

jQuery(document).ready(function(){
    jQuery('.scrollbar-outer').scrollbar();
});
gromo commented 7 years ago
  1. Do not use inline styles to limit height, use classes and set height limit via CSS
  2. Your inner container should have class with height:100%; to be set
clarkk commented 7 years ago

thanks :)

clarkk commented 7 years ago

Ok, I got the first one to work but can't make the second one to work with the outer container..

https://jsfiddle.net/kk1sy7ve/6/

.test-outer {
  max-height:100px;
}

.scrollbar_content {
    height:100%;
    overflow:auto;
}

<h1>Simple outer (content height)</h1>
<div class="test-outer">
<div class="scrollbar-outer scrollbar_content">
    <p>
        Simple outer scrollbar can be used as CSS base for custom outer scrollbars.
        This example shows nested scrollbars functionality: nested scrollbar styles do not
        interfere with parent scrollbar styles, i.e. different scrollbars can be safely used
        inside each other.
    </p>
    <p>
        Simple outer scrollbar can be used as CSS base for custom outer scrollbars.
        This example shows nested scrollbars functionality: nested scrollbar styles do not
        interfere with parent scrollbar styles, i.e. different scrollbars can be safely used
        inside each other.
    </p>
    <p>
        Simple outer scrollbar can be used as CSS base for custom outer scrollbars.
        This example shows nested scrollbars functionality: nested scrollbar styles do not
        interfere with parent scrollbar styles, i.e. different scrollbars can be safely used
        inside each other.
    </p>
</div>
</div>
gromo commented 7 years ago

Yep, you're right, the second one won't work this way. You have to set fixed height to outer container or apply max-height to scrollbar container.