gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 11:28:44 24 4
gpt4 key购买 nike

根据 Mozilla 开发者网络的 article在 CSS position 属性上,将 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)。它是如何推导或暗示的?

最佳答案

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

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com