Home > Enterprise >  Why `container-type: size` CSS prop sets height to zero?
Why `container-type: size` CSS prop sets height to zero?

Time:11-18

And how to bring height back, keeping container-type: size in place? Sample: https://jsfiddle.net/yakunins/cy3b68uk/

<div style="container-type: size;">Height of this div is zero.</div>

CodePudding user response:

Because it sets size containment. A size container cannot depend on the size of its contents, so it behaves as if its content size is 0.

You must set an explicit height for the size container.

CodePudding user response:

Container type doesn't have full support yet, as of 18th Nov 22.

Elements that use container size must have a defined size property, as the child elements will use a portion of this to calculate their own sizes.

  • Related