flexbox Flashcards
Why is flexbox in CSS?
For a long time floats and positioning were chaotic across browsers.
Flexbox was designed to make it easier to:
**vertically center a block inside its parent
**make all children take up an equal amount of width/height
**make all columns in a layout adopt the same height
How do you define a flexbox?
display: flex;
this element will have block scope and it’s children are laid out as flex items.
What is the flex model?
Flex items are laid out along two axis:
Main : defined with flex-direction
Cross: runs perpendicular to the main axis
What can you specify with flex-direction?
flex-direction: main;
row, row-reverse. [left-to-right, right-to-left]
column, column-reverse
What is flex-flow?
shorthand for direction and wrapping.
flex-flow: direction wrap;
wrap is [nowrap, wrap, wrap-reverse]
How do you align items and content inside a flexbox?
align-items, and justify-content
What are the align-items options?
cross-axis alignment
stretch [default], center, flex-start, flex-end
What is the flex property?
Shorthand for flex-grow, flex-shrink, and flex-basis
/* Three values: flex-grow | flex-shrink | flex-basis */
flex: 2 2 10%;
/* Keyword values */
flex: auto;
flex: initial;
flex: none;
What does justify-content control?
main-axis alignment
what is flex-basis?
controls the initial size of the element before additional space is distributed.
what is flex-grow?
controls the amount of available space an element could take up
what is flex-shrink?
if items are larger than the container, they shrink according to flex shrink.