I have a container that effectively, I want to compress the contents to their minimum width without scroll bars. fit-content is close, but allows the content to use more width than it actually needs. I could also explicitly set the container's width, but that requires me to know the min-width of the contents ahead of time.
So in the example below, the box width should default to compressing the inner item to 3 lines. How can the box reclaim this bit of space?
.box { background-color: green; resize: both; overflow: auto; padding: 1em; min-width: 2em; width: fit-content; height: 10em; } .el { background-color: teal; width: 100%; min-width: 5em; } <div class="box"> <div class="el"> Lorem isa psalm ipsom </div> </div>