CSS Flexbox
With 10 items:
With 2 items:
CSS Flex Container (Parent Element)
The flex-direction property
The column value stacks the flex items vertically (from top to bottom):
The column-reverse value stacks the flex items vertically (but from bottom to top):
The row value stacks the flex items horizontally (from left to right):
The row-reverse value stacks the flex items horizontally (but from right to left):
The flex-wrap Property
The wrap value specifies that the flex items will wrap if necessary:
1
2
3
4
5
6
7
8
9
10
11
12
The nowrap value specifies that the flex items will not wrap:
1
2
3
4
5
6
7
8
9
10
11
12
The wrap-reverse value specifies that the flexible items will wrap if necessary, in reverse order:
1
2
3
4
5
6
7
8
9
10
11
12
The justify-content Property
The center value aligns the flex items at the center of the container:
The flex-start value aligns the flex items at the beginning of the container:
The flex-end value aligns the flex items at the end of the container:
The space-around value displays the flex items with space before, between, and after the lines:
The space-between value displays the flex items with space between the lines:
The align-items Property
The center value aligns the flex items in the middle of the container:
The flex-start value aligns the flex items at the top of the container:
The flex-end value aligns the flex items at the bottom of the container:
The stretch value stretches the flex items to fill the container:
The baseline value aligns the flex items such as their baselines aligns:
The align-content Property
The space-between value displays the flex lines with equal space between them:
1
2
3
4
5
6
7
8
9
10
11
12
The space-around value displays the flex lines with space before, between, and after them:
1
2
3
4
5
6
7
8
9
10
11
12
The stretch value stretches the flex lines to take up the remaining space:
1
2
3
4
5
6
7
8
9
10
11
12
The center value displays display the flex lines in the middle of the container:
1
2
3
4
5
6
7
8
9
10
11
12
The flex-start value displays the flex lines at the start of the container:
1
2
3
4
5
6
7
8
9
10
11
12
The flex-end value displays the flex lines at the end of the container:
1
2
3
4
5
6
7
8
9
10
11
12
CSS Flex Items (Child Elements)
The order Property
The direct child elements of a flex container automatically becomes flexible (flex) items.
The order property can change the order of the flex items:
The flex-grow Property
The flex-grow property specifies how much a flex item will grow relative to the rest of the flex items.
The flex-shrink Property
The flex-shrink property specifies how much a flex item will shrink relative to the rest of the flex items.
The flex-basis Property
The flex-basis property specifies the initial length of a flex item.
The align-self Property
The align-self property specifies the alignment for the selected item inside the flexible container.
The align-self property overrides the default alignment set by the container's align-items property.
CSS Flex Responsive
Responsive Flexbox
The "flex-direction: row;" stacks the flex items horizontally (from left to right).
The "flex-direction: column;" stacks the flex items vertically (from top to bottom).
Resize the browser window to see that the direction changes when the screen size is 800px wide or smaller.
Responsive Website using Flexbox
Use flexbox to create a responsive website, containing a flexible navigation bar and flexible content:
Resize the browser window to see the responsive effect.
About Me
Photo of me:
Image
Some text about me in culpa qui officia deserunt mollit anim..
More Text
Lorem ipsum dolor sit ame.
Image
Image
Image
TITLE HEADING
Title description
Image
Some text..
Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
TITLE HEADING
Title description
Image
Some text..
Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.