Pick the key flex properties and immediately get the matching display:flex CSS with a live preview of one, two and three items.
| Item | Formula / Note | Source / Standard |
|---|---|---|
| Main and cross axis | flex-direction sets the main axis, the cross axis stays perpendicular | CSS Flexible Box Layout Level 1 |
| Flex resolution | free space follows flex-grow weights, deficits follow flex-shrink | CSS Flexible Box Layout Level 1 |
| Alignment | justify-content handles the main axis, align-items the cross axis | CSS Flexible Box Layout Level 1 |
| 属性 | 常用取值 | 说明 |
|---|---|---|
| flex-direction | row / column / row-reverse / column-reverse | 主轴方向 |
| justify-content | flex-start / center / flex-end / space-between / space-around / space-evenly | 主轴对齐 |
| align-items | stretch / flex-start / center / flex-end / baseline | 交叉轴对齐 |
| flex-wrap | nowrap / wrap / wrap-reverse | 是否换行 |
| gap | 任意长度(如 12px) | 项目间距 |
提示:要让单个项目在交叉轴居中可用 align-self;要控制项目伸缩用 flex: 1 或 flex-grow/shrink/basis。