Display only the number of items that will fit, and then expand to fit snugly

Viewed 1960

I have a container that I want to fit a number of children in horizontally, but I know I have more children than will often fit.

+-----------------------+
|                       |
|                       |
+-----------------------+

+----+ +----+ +----+ +----+ +----+ +----+ 
|    | |    | |    | |    | |    | |    | 
|    | |    | |    | |    | |    | |    | 
+----+ +----+ +----+ +----+ +----+ +----+ 

Using only CSS, how do I only display the items that can fit, and expand them to fit snugly?

Desired result:

+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+
2 Answers
Related