· 6 min read
Flexbox 是 容器定方向,子项定大小 两套属性加起来 12 个的事。
- 启动:
display: flex一行,元素变弹性容器 - 容器 6 属性:flex-direction / flex-wrap / justify-content / align-items / align-content / gap
- 子项 6 属性:flex-grow / flex-shrink / flex-basis / flex / order / align-self
- 核心思路:先想主轴(默认水平),再选对齐方式
- 现代选择:
gap替代margin间距 - 常见坑:主轴 / 交叉轴搞反,90% 的 flex bug 都是这个
- 默认行为:grow=0 / shrink=1(不抢必缩)





