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

标签 css language-lawyer w3c

根据 Mozilla 开发者网络的 article关于 CSS position属性(property)、环境positionabsolute有以下行为:

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 的计算定位属性)。它是如何推论或暗示的?

最佳答案

它在规范中(您查看的是错误的文档):

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.

关于css - CSS规范中找不到绝对定位规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41306265/

相关文章:

jquery - 检测是否显示 div - 差异与空 div?

c++ - memcpy 是可简单复制的类型构造还是赋值?

c - C89 标准中的哪一部分允许 "implicit int"规则?

html - 如何使 youtube 嵌入代码 HTML 对 w3c 验证器有效?

javascript - 在 HTML/CSS 中自定义和定位垂直 slider

html - 使用媒体查询获得完美图像响应的正确方法是什么?

css - margin 崩溃和清除

javascript - JavaScript DOMParser node.xml 的 W3C 等效项?

javascript - 将新文本置于旧文本之上

关于 IEC 60559 附录的说明