gromo / jquery.scrollbar

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

scrollbar doesn't work when setting height not using class #123

Closed w-gr closed 7 years ago

w-gr commented 7 years ago
<style type="text/css">
        #test {
            height: 50px;
            overflow: hidden;
        }
</style>

<div class="demo">
    <div id="test" class="scrollbar-inner">
        <p class="permanent">
            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>

The new version of scrollbar 0.2.11 doesn't work if I set the height not using class, like ID in the example. I find a way to fix this issue is set the height to empty of cssOptions.

cssOptions = {
    "height": "",
    "margin-bottom": browser.scroll.height * -1 + 'px',
    "max-height": ""
};

It worked well before version 0.2.8.

gromo commented 7 years ago

Set height/max-height using CSS classes, not IDs, because custom scrollbar duplicate element, and ID should be unique per page.

w-gr commented 7 years ago

@gromo the same issue with HTML tags like fieldset. Is it possible to fix this issue not using a class?

gromo commented 7 years ago

Why not CSS classes? They are designed to be used for this purpose. Add new additional unique class to your container and that's all.

w-gr commented 7 years ago

@gromo Much appreciated. I think it would be better to add this: only using unique class to control the height to document. Thanks a lot.