在 CSS 规范中找不到绝对定位规则

Can't find absolute positioning rules in CSS specification

根据 CSS position 属性 上 Mozilla Developer Network 的 article,将 position 设置为 absolute 具有以下行为:

absolute

Do not leave space for the element. Instead, position it at a specified position relative to its closest positioned ancestor if any, or otherwise relative to the initial containing block. Absolutely positioned boxes can have margins, and they do not collapse with any other margins.

但是,在官方 CSS specification as of 2015 中我找不到它在哪里声明包含框或最近的祖先需要定位的约束(即必须有一个计算定位 属性 relativeabsolutefixedsticky)。它是如何推导或暗示的?

根据 2015 年的官方 CSS 规范是:

This document collects together into one definition all the specs that together form the current state of Cascading Style Sheets (CSS) as of 2015. The primary audience is CSS implementers, not CSS authors, as this definition includes modules by specification stability, not Web browser adoption rate.

在上面的link里面你可以找到一个link到CSS2,在里面你可以找到这个:

9.6 Absolute positioning

In the absolute positioning model, a box is explicitly offset with respect to its containing block. It is removed from the normal flow entirely (it has no impact on later siblings). An absolutely positioned box establishes a new containing block for normal flow children and absolutely (but not fixed) positioned descendants. However, the contents of an absolutely positioned element do not flow around any other boxes. They may obscure the contents of another box (or be obscured themselves), depending on the stack levels of the overlapping boxes.

它在规范中(您看错了文档):

9.8.4 Absolute positioning

The containing block for a positioned box is established by the nearest positioned ancestor (or, if none exists, the initial containing block).

这也是相关的:

9.3.2 Box offsets: top, right, bottom, left

An element is said to be positioned if its position property has a value other than static.