Let's say I have a series of <li>
elements designed to render via float:left inside a fixed-width container as follows:
Item 1 | Item 2 | Item 3 | Item 4
| Item 5 | Item 6
This is fine, Item 5 and Item 6 are pushed to the second row because the container has a fixed width.
Now, is it possible to have something similar to above, except that majority of the items will render in the second row? Something like:
Item 1 | Item 2
| Item 3 | Item 4| Item 5 | Item 6
Basically, I want to render a list of items horizontally, wrapping to the second row as needed, but with majority of the items on the second row if it exists. The number of items to be generated may vary, but will not exceed 2 rows' worth of items.
If you enjoyed my content for some reason, I'd love to hear from you! Here are some options:
- You can buy me a coffee!
- Click here to post a comment!
- You can write a reply on your own site and submit the URL as a webmention via the form below.
- Or you can just contact me!
Not without either manually defining which item starts the new line (with clear:both;), or using javascript to figure out which item should break, and then doing the same as above.
via stackoverflow.com