Don't require CSS height or max-height
See original GitHub issueCurrently mCustomScrollbar()
requires the container div to have “height” or “max-height” CSS attribute. That’s is not very cool in cases in which we don’t want to set such attributes (i.e. when using the new W3C FlexBox model with “flex-direction: column” in which the divs can fill the entire vertical space of the main box).
Why is “height” or “max-height” CSS attribute required? why not get the height via jQuery height()
method?
Issue Analytics
- State:
- Created 10 years ago
- Comments:19 (7 by maintainers)
Top Results From Across the Web
max-height - CSS: Cascading Style Sheets - MDN Web Docs
The max-height CSS property sets the maximum height of an element. It prevents the used value of the height property from becoming larger ......
Read more >Child with max-height: 100% overflows parent - css
When you specify a percentage for max-height on a child, it is a percentage of the parent's actual height, not the parent's max-height...
Read more >max-height | CSS-Tricks
The max-height property in CSS is used to set the maximum height of a specified element. Authors may use any of the length...
Read more >Min and Max Width/Height in CSS - Ahmad Shadeed
In this article, we will go through the maximum and minimum CSS properties for width and height, and to explain each one in...
Read more >CSS Properties – Max-width, Min-width, Max-height, and Min ...
The Max-Height Property ... The max-height property operates similarly to the max-width property, but it affects the height instead of the width.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having good success with 3.1.3 using flexbox with all browsers except Safari. With Safari, my container is set to:
Which results in the .mCustomScrollBox height at 0 in Safari.
The style for this container is setting style=“max-height:280px” (for example) as calculated. This works for everyone but safari. For safari, it needs either min-height or height also set to this value (height:280px) for it to render correctly.
Here’s the fix:
I cannot see any scrollbar on the example.
In order to make the yellow box have a scrollbar you must set a max-height value on it and since you have fixed height values, you can set its max-height:125px;. In your example, you’ve set height values for everything but the yellow box, so you don’t need jQuery to set its height. 200px minus 25px minus 50px equals 125px. You can apply that in your css. You could also do this with percentages.
A scrollbar cannot work without a height/max-height (like in your example, where no scrollbar is present). This applies on any kind of scrollbar (browser, javascript, whatever…).
If there’s no height, how can an engine know when to stop expanding an overflow:auto element and apply a scrollbar?
Additionaly, The custom scrollbar plugin has the set_height option parameter, where you can set its value to pixels or percentage. For example: