#Using CSS to tightly pack elements?

1 messages · Page 1 of 1 (latest)

tacit wolf
#

Is it possible to use pure CSS to pack a container of elements as tightly as possible? I have a list of music artists with different length names in a scroll container and I want to try and arrange them such that they pack nicely and minimise the horizontal space either side of them.

Was wondering if this is something that could be done with CSS grid, perhaps? I played around with grid-auto-flow but having made any headway

#

looks like CSS grid can do it if you define the widths of elements with stuff like grid-column: span 2 but I was looking for a way to use the computed width of an element

dim heart
#

Does the order of the artists matter? Or are you saying you want the artists rearranged such that the space is minimized?

tacit wolf
tacit wolf
#

maybe I should look into making one

urban roost
#

Have you tried flex and flex-wrap?