Why is the height of the parent 200px instead of 300px in the following example?
#p {
height: 200px;
min-height: max-content;
border: 1px solid blue;
}
#c {
margin: 0 50px 0 50px;
height: 300px;
background: red;
}
<div id="p">
<div id="c">
</div>
</div>
If I set height: max-content directly, the height will be set correctly to 300px. Doesn't this mean max-content = 300px in this case? Therefore shouldn't min-height: max-content be the same as min-height: 300px?
#p {
height: max-content;
border: 1px solid blue;
}
#c {
margin: 0 50px 0 50px;
height: 300px;
background: red;
}
<div id="p">
<div id="c">
</div>
</div>
And apparently there is no "conflict" between height and min-height:
#p {
height: 200px;
min-height: 400px;
border: 1px solid blue;
}
#c {
margin: 0 50px 0 50px;
height: 300px;
background: red;
}
<div id="p">
<div id="c">
</div>
</div>
Moreover, if you change height and min-height to width and min-width, it works as expected. Why?
#p {
width: 200px;
min-width: max-content;
border: 1px solid blue;
}
#c {
margin: 0 50px 0 50px;
width: 300px;
background: red;
}
<div id="p">
<div id="c">
hello
</div>
</div>
