What is Flexbox?
Flexbox is modern grid layout which provides a more efficient way to lay out, align and alocate space among items in container.It’s supported from all of modern browsers and it is using more and more on regular basis for better responsive websites. It’s like float layout on steroids.
Container (flex container) properties
#display
To define a flex-container we need to add:
display: flex or inline-flex
container {
display: flex;
}
#flex-direction
To select direction in which items will layer we use:
flex-direction
row(default)row-reversecolumncolumn-reverse
.container {
flex-direction: row;
}
#flex-wrap
To wrap items we use:
flex-wrap
nowrap(default) all items will be on one linewrapwrap items from top to bottomwrap-reversewrap items from bottom to top
.container {
flex-wrap: wrap;
}
#justify-content
To choose alignment along the main axis of individual items:
justify-content
flex-start(default) items are in the start line(left)flex-enditems are in the end line (right)centeritems are in the centerspace-betweenitems are evenly in the linespace-arounditems are evenly in the line with space around themspace-evenlyitems are evenly in the line so that the spacing between two items is equal
.container {
justify-content: flex-start;
}
#align-items
To choose alignment along the cross axis of individual items(like justify-content but for cross-axis):
justify-content
flex-startitems are in the start of the cross-axisflex-enditems are in the end of the cross-axiscenteritems are in the center of the cross-axisbaselineitems are aligned as their baselines alignstretch(default)stretch to fill the container
.container {
align-items: flex-start;
}
Items (flex items) properties
#order
To change order of appearing of the items use:
order: default is 0
.item {
order: 99;
}
#flex-grow
To set what amount of available space to take item in the container use:
flex-grow: default is 0
.item {
flex-grow: 3;
}
#flex-shrink
Ability of the item to shrinks:
flex-shrink: default is 1
.item {
flex-shrink: 1;
}
That is the main properties of the flex grid layout, there is few more. If you want more info about Flexbox layout model you can read about it here

Comments are closed.