Recommended path for Flex experimentation:
-
Decide on your container:
.container { display: flex; }
-
Experiment with the following shorthand
flex
declarations without wrapping in therow
direction (default):flex: 0 auto
(default; same asflex: initial
);flex: auto
;flex: none
;flex: <integer>
.
-
Add responsiveness to the above with media queries.
-
Add wrapping (
flex-wrap: wrap
) with fixed item sizes (no growing/shrinking):.container { display: flex; flex-wrap: wrap } .container > * { flex: 0 0 <length>; }
OR:
.container > * { flex: 0 0 auto; }
...and set a fixed size to the item content.
-
Mix wrapping with variable sized items.
-
Limit growth and shrinkage with
min-width
andmax-wdith
.