I have a problem with the property flex
in css
: I am giving it a value of justify-content: flex-start
to order my HTML elements, the problem is that the number of elements can increase or decrease, and when the elements increase, the elements get smaller and smaller until they become deformed my layout.
Is there a way that once there is a certain amount of elements, the other elements go down to the second line or second block?
you just need
flex-flow: wrap;
What this does is say how the child elements are going to be composed, you can see more about this here
When you add the property
display
with valueflex
, there are two styles that are defined by default:flex-direction: row
andflex-wrap: nowrap
. All you have to do is change the value of the propertyflex-wrap
towrap
and make sure the value offlex-direction
isrow
.There is a shortland property called
flex-flow
, where you can join values of both ,flex-direction
andflex-wrap
, like this:flex-flow: row wrap
.I leave you a site that has helped me understand the use of flexbox technology in CSS.