FNCはfloat親要素を拡張できますが、絶対位置要素の親要素を拡張できません.

2434 ワード

テキストリンク:https://segmentfault.com/q/1010000000686154/a-1020000000686760
W 3 C規格のアルゴリズムでは、floatが親高さ計算に関与する可能性があるが、position:absolute;は常に親計算に関与しない.このように設計されていますが、仕方がありません.
W3C CSS2.1 10.6.3 BFCが作成されていない非置換ブロックレベル要素の高さ計算規則を規定する:
This section also applies to block-level non-replaced elements in normal flow when 'overflow' does not compute to 'visible' but has been propagated to the viewport.
If 'margin-top', or 'margin-bottom' are 'auto', their used value is 0. If 'height' is 'auto', the height depends on whether the element has any block-level children and whether it has padding or borders:
The element's height is the distance from its top content edge to the first applicable of the following:
  • the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
  • the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin does not collapse with the element's bottom margin
  • the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin
  • zero, otherwise

  • 上記のように、セクション1はline-box拡張コンテナを定義し、セクション2と3は従来のストリームブロックレベル要素拡張コンテナ(marginが折り畳まれているかどうかの2つの場合)を定義し、そうでない場合は0です.
    W3C CSS2.1 10.6.7 BFCを作成した要素(block formatting context roots)の高さ計算規則を規定する.
    If it only has inline-level children, the height is the distance between the top of the topmost line box and the bottom of the bottommost line box. If it has block-level children, the height is the distance between the top margin-edge of the topmost block-level child box and the bottom margin-edge of the bottommost block-level child box. Absolutely positioned children are ignored, and relatively positioned boxes are considered without their offset. Note that the child box may be an anonymous block box. In addition, if the element has any floating descendants whose bottom margin edge is below the element's bottom content edge, then the height is increased to include those edges. Only floats that participate in this block formatting context are taken into account, e.g., floats inside absolutely positioned descendants or other floats are not.
    ここでの規則はほぼ上と同様であり,marginが折り畳まれずfloat高さが計算に関与しない点が異なる.
    要するに、「親容器の輪を高くする」には絶対的な位置決め要素の地位はありません.