P粉2001385102023-08-25 10:39:34
The scope of a flex formatting context is limited to parent-child relationships.
This means that the flex container is always the parent, and the flex items are always the children. Flex properties only work within this relationship.
Descendants of a flex container that exceeds the child level do not belong to the flex layout and will not accept flex attributes.
In order to apply flex properties to children, you always need to apply display: flex
or display: inline-flex
to the parent.
Some flex properties only apply to flex containers (such as justify-content
, flex-wrap
, and flex-direction
), while some flex properties Applies only to flex items (such as align-self
, flex-grow
, and flex
).
However, flex items can also be flex containers. In this case, the element can accept all flex properties. Since each property performs a different function, there are no internal conflicts and nothing needs to be overridden.