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-content
andalign-items
allows you to move the elements left and right, up and down- If
flex-direction
isrow
orrow-reverse
(default value),justify-content
will move elements left and rightalign-items
will move elements up and down
- If
flex-direction
iscolumn
orcolumn-reverse
,justify-content
will move elements up and downalign-items
will move elements left and right
- If
-
justify-content
takes the following values:flex-start
flex-end
center
space-between
space-around
space-evenly
-
align-items
takes the following values:flex-start
flex-end
center
baseline
stretch
-
flex-wrap
allows 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! 😃