display: flexThis element will use the flexible box layout method to size all its children.
display: inline-flexblock : inline-block :: flex : inline-flex
flex-directionflex-wrapflex-flowjustify-contentalign-contentalign-itemsflex-directionSet the main axis that flex properties work along
row — horizontalcolumn — verticalrow-reversecolumn-reverseflex-wrapAllow children to wrap inside the flex container
nowrapwrapwrap-reverseflex-flowShorthand for flex-direction & flex-wrap
row wrapcolumn wrap-reverserow-reverse nowrapjustify-contentDistributes children along the main axis of the flex container
startendcenterleftrightjustify-contentDistributes children along the main axis of the flex container
baselinefirst baselinelast baselinejustify-contentDistributes children along the main axis of the flex container
space-betweenspace-aroundspace-evenlystretchjustify-contentDistributes children along the main axis of the flex container
safeunsafealign-contentDistributes children along the cross axis of the flex container
startendcenteralign-contentDistributes children along the cross axis of the flex container
baselinefirst baselinelast baselinealign-contentDistributes children along the cross axis of the flex container
space-betweenspace-aroundspace-evenlystretchalign-contentDistributes children along the cross axis of the flex container
safeunsafealign-itemsAligns children on the cross axis of the flex container
startendcenterself-startself-endalign-itemsAligns children on the cross axis of the flex container
baselinefirst baselinelast baselinealign-itemsAligns children on the cross axis of the flex container
space-betweenspace-aroundspace-evenlystretchalign-itemsAligns children on the cross axis of the flex container
safeunsafeflex-growflex-shrinkflex-basisorderalign-selfflex-growHow much of the extra space on the main axis the element is allowed to take up
Relative to flex-grow of siblings
Values: integer
flex-shrinkHow much of the necessary shrinking on the main axis the element must do
Relative to flex-shrink of siblings
Values: integer
flex-basisHow much space on the main axis the element takes up before growing or shrinking
Values: length
auto means the element’s width
flexShorthand:
grow shrink basis
orderChange the element’s location along the main axis
Relative to order of all siblings
align-selfAllows the element to override its parent’s align-items value
Value: any align-items value
.container {
display: flex;
justify-content: center;
align-items: center;
}
.parent {
display: flex;
justify-content: space-between;
}
.child {
/* 3 columns, 20px gap */
width: calc(33% - (20px * 2 / 3));
}
.parent {
display: flex;
justify-content: space-between;
align-items: stretch;
}
.child {
/* 3 columns, 20px gap */
width: calc(33% - (20px * 2 / 3));
}
Flexbox is 1-dimensional: it sets a main axis and provides controls for positioning elements along that axis.
Grid is 2-dimensional: it sets both block and inline axes and provides controls for positioning elements along either/both axes.
jdsteinbach