✨ Flexbox Layout Generator
Pick the key flex properties and immediately get the matching display:flex CSS with a live preview of one, two and three items.
📐 工作原理與說明
display: flex;flex-direction / flex-wrap / justify-content / align-items / gap 組合
把 flex-direction、wrap、justify-content、align-items、gap 等屬性拼裝為 display:flex 宣告,並以 1 / 2 / 3 個專案即時演示排列效果;用於一維佈局。
Formula & Standard References
| 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 |
⚠️ 使用說明與注意事項
- justify-content 控制主軸(由 flex-direction 決定水平或垂直)上的對齊與分佈。
- align-items 控制交叉軸上的對齊;stretch 會讓專案拉伸填滿交叉軸。
- flex-wrap:wrap 允許換行,配合 gap 可快速實現自適應網格。
🧩 flex 屬性速查
| 屬性 | 常用取值 | 說明 |
|---|---|---|
| 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。