rochal / jQuery-slimScroll

small jQuery plugin that transforms any div into a scrollable area with a nice scrollbar. Demo and more:
http://rocha.la/jQuery-slimScroll
2.23k stars 928 forks source link

Scrollbar is displayed in error if element has a border #296

Open philipstratford opened 6 years ago

philipstratford commented 6 years ago

Firstly I'd like to say that I think this plugin is excellent and, of the many plugins out there designed for this purpose, this is the one I've found the nicest to work with.

If I apply slimScroll to an element with a max-height property set and the contents of that element is smaller in height than the max-height value of its parent, the slimScroll scrollbar is not displayed. Once the contents' height exceeds the parent's max-height value, the scrollbar is displayed. This is exactly as expected.

However, if the parent element has a border - for example border: 1px solid black - the scrollbar is always displayed, even if the contents of the element are not taller than the parent's max-height value and a scrollbar is not required.

I've created a fiddle to demonstrate the problem here. Note that the div has an unnecessary scrollbar at all times, but that if you remove the border property from its style the scrollbar disappears and functions as normal (i.e. if you had more <li> elements the scrollbar will be displayed as expected.