Professional Documents
Culture Documents
<div class="parent">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
flex-container flex-item </div>
F L E X B OXS I M P L I F I E D. C O M | TA K E C O N T R O L O F F L E X B O X
F L E X B OX A L I G N M E N T & J U S T I F I C AT I O N
parent {
display: flex; This takes the available space
justify-content: space-between; on the main-axis, and puts it
} between the children.
100px
parent {
display: flex; This takes the available space
justify-content: space-around; on the main-axis, and puts it
} around the children.
100px
F L E X B OXS I M P L I F I E D. C O M | TA K E C O N T R O L O F F L E X B O X
F L E X B OX A L I G N M E N T & J U S T I F I C AT I O N
parent {
display: flex; This pushes all the children
justify-content: flex-start; to the start of the main-axis
} (default behaviour)
parent {
display: flex; This pushes all the children to
justify-content: flex-end; the end of the main-axis
}
parent {
display: flex; This centers all the children
justify-content: center; along the main-axis
}
F L E X B OXS I M P L I F I E D. C O M | TA K E C O N T R O L O F F L E X B O X
F L E X B OX A L I G N M E N T & J U S T I F I C AT I O N
parent {
display: flex; The default behavior, causing
align-items: stretch; all elements to have the same
} size on the cross-axis (height,
in the example below)
Lorem ipsum Lorem ipsum quad Lorem ipsum quad Lorem ipsum
dium allo nserisquod dium allo nserisquod
quid qui occum hilArum
quibus dolendam
re nobitis modi cum
expero ex.
parent {
display: flex; All the items will have their
align-items: flex-start; intrinsic (default) size on the
} cross-axis, and align along
the start of that axis.
Lorem ipsum Lorem ipsum quad Lorem ipsum quad Lorem ipsum
dium allo nserisquod dium allo nserisquod
quid qui occum hilArum
quibus dolendam
re nobitis modi cum
expero ex.
parent {
display: flex; All items will be center
align-items: center; aligned along the cross-axis.
}
F L E X B OXS I M P L I F I E D. C O M | TA K E C O N T R O L O F F L E X B O X
F L E X B OX A L I G N M E N T & J U S T I F I C AT I O N
parent {
display: flex; All the items will have their
align-items: flex-end; intrinsic (default) size on the
} cross-axis, and align along
the end of that axis.
parent {
display: flex; The first line of text for all
align-items: baseline items will align on the same
} baseline.
Lorem ipsum Lorem ipsum quad Lorem ipsum quad Lorem ipsum
dium allo nserisquod dium allo nserisquod
quid qui occum hilArum
quibus dolendam
re nobitis modi cum
expero ex.
parent { main-axis
display: flex; cross-axis
flex-direction: column;
}
The default flex-direction is row. This is on the parent,
so the parent is a row, and the children are columns.
When we declare flex-direction: column, the parent is
a column, and the children become rows.
F L E X B OXS I M P L I F I E D. C O M | TA K E C O N T R O L O F F L E X B O X