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-reverse
column
column-reverse
.container { flex-direction: row; }
#flex-wrap
To wrap items we use:
flex-wrap
nowrap
(default) all items will be on one linewrap
wrap items from top to bottomwrap-reverse
wrap 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-end
items are in the end line (right)center
items are in the centerspace-between
items are evenly in the linespace-around
items are evenly in the line with space around themspace-evenly
items 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-start
items are in the start of the cross-axisflex-end
items are in the end of the cross-axiscenter
items are in the center of the cross-axisbaseline
items 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.