mardi 18 août 2020

HTML / CSS div :: Why does height: auto = 0?

Every now and then, this bites me in the butt. I work on a web page and, dealing with dynamic content, set the height of a div to auto. I know it is wrong to think that the div would just automagically expand its height to the content that will populate it. Still, this is not entirely a rhetorical question, but I do not understand why, in this case auto equals 0.

Why bother with auto in the first place?

Aside from CSS flexbox or grid, what would be a simple approach to avoid a zero-height div, when I don't know how much (or little) text will ultimately reside in it?




Aucun commentaire:

Enregistrer un commentaire