Ahmad Shadeed covers the CSS fit-content sizing key phrase. It’s helpful! It simply doesn’t come up tremendous usually. I discover myself utilizing min-content much more, like when organising the peak of a grid-template-row.
The fit-content key phrase is definitely carefully associated to min-content and max-content — it simply has a little bit heuristic it follows that Ahmad properly illustrates as a movement chart.
“Use Instances For CSS fit-content” by Ahmad Shadeed
My favourite use case is roofed right here: sizing a <determine> with fit-content, in order that it neatly wraps across the <img>. That means, even when the picture doesn’t fill the father or mother house, and it may well stay block-level.
We additionally lined PPK’s deep dive on fit-content final yr. One of many key takeaways for understanding it’s figuring out that’s it basically a shorthand means of writing:
/* … is similar as … */