2
If I use display:flex in a structure ul>li, all items will be squeezed into a single row. I wonder if it is possible to determine the limit per line, for example three..
I can do with float:left, but I’d like to use flexbox..
Ex: Determine that three LI will appear per line
<ul>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
The question is interesting. If you know how to do with float:left, flexbox is similar. You can set a minimum width on each block so that it only fits 3 on the line. Now, a curiosity: What is the advantage of using flex-box if it will have fixed amount of items per line? Another caution: if, by chance, you are doing something with a table function (presenting naturally tabulated data), the correct element is
<table>. (But it’s funny, some people don’t understand that thetable, provided that used correctly, ie for tables, is an element as valid as any other).– Bacco
I’m still not sure if I’ll use flex or float, but when I went to develop, I came up with both ideas, and then the doubt arose.. I think that would be an option, something else, you know? There would be an example on top of the question html?
– Cobra
I believe that
li {min-width:30%}already solve. The good thing about the flex relative to the float is that you make the fill of the line be 100%, what with float is more boring because of the roundness of the percentages. Putting the current CSS in your example makes it easier for someone to give a more complete answer.– Bacco
I believe it’s just that, it was just an idea that came to me! Anyway, and once again, thank you!
– Cobra