The main idea behind the flex layout is to give the container the ability to alter its items' width/height (and order) to best fill the available space (mostly to accommodate to all kind of display devices and screen sizes). A flex container expands items to fill available free space or shrinks them to prevent overflow.
https://stackoverflow.com/questions/37815450/flex-items-ignoring-width
-
Apply
display: flex;on the parent of the elements you are trying to arrange. -
justify-contentandalign-itemsallows you to move the elements left and right, up and down- If
flex-directionisroworrow-reverse(default value),justify-contentwill move elements left and rightalign-itemswill move elements up and down
- If
flex-directioniscolumnorcolumn-reverse,justify-contentwill move elements up and downalign-itemswill move elements left and right
- If
-
justify-contenttakes the following values:flex-startflex-endcenterspace-betweenspace-aroundspace-evenly
-
align-itemstakes the following values:flex-startflex-endcenterbaselinestretch
-
flex-wrapallows you to spread your elements out if they don't all fit in the same row- They would go to a new row instead of getting squished
That is perfectly fine! The key point is understand how
display: flex;works and what are the things you can do with it. It is okay if you can't remember them all at once, you can always Google or ask us! 😃