Sources
S1 — MDN: Basic concepts of flexbox
URL: https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Flexible_box_layout/Basic_concepts
- authority: official-docs
- supports: 第 1-3 课:
display: flex做什么、直接子元素成为 flex item、主轴与交叉轴,以及justify-content沿主轴对齐、align-items沿交叉轴对齐。 - key-fact: "To create a flex container, set the area's
displayproperty toflex. When we do this, the direct children of that container become flex items." "The main axis is defined byflex-direction." "The cross axis runs perpendicular to the main axis." "Thejustify-contentproperty is used to align the items on the main axis." "Thealign-itemsproperty aligns all the flex items on the cross axis."
S2 — MDN: Aligning items in a flex container
URL: https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Flexible_box_layout/Aligning_items
- authority: official-docs
- supports: 第 2 课:把
justify-content: center(主轴)和align-items: center(交叉轴)组合起来,在两条轴上同时居中一个元素。 - key-fact: "To center an element, we use the
align-itemsproperty to align the item on the cross axis... We usejustify-contentto align the item on the main axis, which in this case is the inline axis running horizontally."
S3 — MDN: flex-direction
URL: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/flex-direction
- authority: official-docs
- supports: 第 3 课:
flex-direction设定主轴和 item 流动的方向;默认值是row;column让主轴变为垂直。 - key-fact: "The
flex-directionCSS property sets how flex items are placed in the flex container defining the main axis and the direction (normal or reversed)." Initial value:row.
S4 — MDN: Controlling ratios of flex items along the main axis
- authority: official-docs
- supports: 第 4 课:
flex-basis设定自由空间分配之前的起始尺寸;flex-grow/flex-shrink按因子划分正/负自由空间;flex: 1借助flex-basis: 0做出等宽 item。 - key-fact: "The
flex-basisproperty specifies the initial size of a flex item before any distribution of the positive or negative free space happens." "Theflex-growproperty specifies the flex grow factor, which determines how much a flex item will grow relative to the other flex items... when positive free space is distributed." "To create three equally-sized items... set theflex-basiscomponent to0."
S5 — MDN: Mastering wrapping of flex items
URL: https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Flexible_box_layout/Wrapping_items
- authority: official-docs
- supports: 第 5 课:默认的
flex-wrap: nowrap会溢出;flex-wrap: wrap让 item 断到新行;gap属性拉开 flex item 间距,是row-gap/column-gap的简写。 - key-fact: "The initial value of the
flex-wrapproperty isnowrap. This means if a set of flex items is too wide for their flex container, they will overflow it." "add theflex-wrapproperty with a value ofwrap... Items will then wrap onto new lines when they overflow their container." "use thegapproperty directly on the flex container to create a fixed space between adjacent flex items. Thegapproperty is a shorthand forrow-gapandcolumn-gap."
S6 — CSS-Tricks: A Complete Guide to Flexbox
URL: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
- authority: authoritative-guide
- supports: 第 1、4、5 课:主轴/交叉轴的心智模型、容器只摆放直接子元素、推荐使用
flex简写,以及gap只在 item 之间放间距、不放在外边缘。 - key-fact: "The main axis of a flex container is the primary axis along which flex items are laid out" while "the axis perpendicular to the main axis is called the cross axis." "This is the shorthand for flex-grow, flex-shrink and flex-basis combined... It is recommended that you use this shorthand." The
gapproperty "applies that spacing only between items not on the outer edges."
S7 — W3C: CSS Flexible Box Layout Module Level 1
URL: https://www.w3.org/TR/css-flexbox-1/
- authority: official-docs
- supports: 第 1-2 课:规范对主轴、交叉轴的正式定义,以及 flex item 如何沿主轴摆放。
- key-fact: "The main axis of a flex container is the primary axis along which flex items are laid out." "The axis perpendicular to the main axis is called the cross axis." "The flex items are placed within the container starting on the main-start side and going toward the main-end side."