CSS Tutorial
Menu
CSS Advanced
Menu
CSS Responsive
Menu
CSS Grid
Menu
CSS Flexbox
CSS Flexbox Layout Module
Before the Flexbox Layout module, there were four layout modes:
- Block, for sections in a webpage.
- Inline, for text.
- Table, for two-dimensional table data.
- Positioned, for explicit position of an element.
The Flexible Box Layout Module, are easy to design flexible responsive layout structure without making use of float or positioning.
Flexbox Elements
To use the Flexbox model, firstly, specify a flex container.
HTML
Create a Flex Container
1
2
3
A Flexible Layout must have a parent element with the display property set to flex.
Direct child elements(s) of the flexible container automatically becomes flexible items.
CSS
.flex-container {
display: flex;
background-color: DodgerBlue;
}
.flex-container > div {
background-color: #f1f1f1;
margin: 10px;
padding: 20px;
font-size: 30px;
}
Output
Create a Flex Container
1
2
3
A Flexible Layout must have a parent element with the display property set to flex.
Direct child elements(s) of the flexible container automatically becomes flexible items.