Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

max-height: fit-content; not working as expected in Mozilla

This style works for e.g. chrome.

p.ex1 {
    max-height: fit-content;
    height: 250px;
    border:solid 1px black;
    overflow: auto;
}

The intention is to use the whole height, with scrolling, if necessary, but shrink height to fit content if the content is small. However, how is this accomplished in Firefox?

https://www.w3schools.com/cssref/tryit.asp?filename=trycss_dim_max-height

chrome:

chrome

firefox:

firefox

like image 780
Hawk Avatar asked Jun 06 '18 14:06

Hawk


People also ask

How do I fix max-height in CSS?

The max-height property in CSS is used to set the maximum height of a specified element. Authors may use any of the length values as long as they are a positive value. max-height overrides height, but min-height always overrides max-height .

What is Max-height fit content?

The fit-content behaves as fit-content(stretch) . In practice this means that the box will use the available space, but never more than max-content . When used as laid out box size for width , height , min-width , min-height , max-width and max-height the maximum and minimum sizes refer to the content size.

How do I get height fit content in CSS?

If height: auto; the element will automatically adjust its height to allow its content to be displayed correctly. If height is set to a numeric value (like pixels, (r)em, percentages) then if the content does not fit within the specified height, it will overflow.

How do you override max-height in CSS?

maxHeight = 'none'; it will apply the none value to the max-height property of the element, overriding any other valid max-height properties in CSS selection rules that match that element.


1 Answers

Try Using:

p.ex1 {
    max-height: fit-content;
    height: -moz-max-content;
    height: 250px;
    border:solid 1px black;
    overflow: auto;
}

height: -moz-max-content;

This tag will work as 'fit-content' for Mozilla.

like image 104
Dilushika Weerawardhana Avatar answered Oct 03 '22 07:10

Dilushika Weerawardhana