写给自己看的CSS Flexbox Layout Guide 

42 阅读1分钟

父容器属性(dfja)

display flex-flow justify-content align-items

flex-container@1x.webp

gap

  • 不影响边缘
  • 不需要 :last-child
  • Grid / Flex 通用
gap: 16px;        /* 行列统一 */
gap:4px 8px       /* row-gap column gap */
row-gap: 12px;
column-gap: 20px;

flex container properties

属性作用
display启用 flex
flex-direction主轴方向
flex-wrap是否换行
flex-flowdirection + wrap
justify-content主轴对齐
align-items单行交叉轴对齐
align-content多行交叉轴对齐
gap / row-gap / column-gap子项间距

子项属性(fa)

flex align-self order

flex: 0 1 auto; /* 默认:grow + shrink + basis 简写 */

flex: 1;        /* = 1 1 0 */
flex: auto;     /* = 1 1 auto */
flex: none;     /* = 0 0 auto */

flex items properties

属性作用
order排列顺序
flex-grow放大比例
flex-shrink缩小比例
flex-basis初始尺寸
flexgrow + shrink + basis 简写
align-self单个对齐

Reference

css-tricks.com/snippets/cs…