gpt4 book ai didi

css - 在 CSS 视觉格式模型中, "the flow of an element"是什么意思?

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

CSS2 Section 9.3: Positioning schemes :

An element is called out of flow if it is floated, absolutely positioned, or is the root element. An element is called in-flow if it is not out-of-flow. The flow of an element A is the set consisting of A and all in-flow elements whose nearest out-of-flow ancestor is A.

我能理解out of flowin-flow是什么意思,但是不明白最后一句的“nearest out-of-flow ancestor”是什么意思方法。谁能提供一个简单的例子?

最佳答案

资料来源:我是 CSS 规范编辑器。

虽然没有在文本中明确说明,但从定义中暗示只有流外元素(包括最常见的根元素)具有流。流是所有作为流外元素后代的元素,除了那些通过嵌套到另一个流外元素中而“隐藏”的元素。

例如,在:

<html>
<body>
<p id=one>some in-flow text
<div style="position: absolute;">
<p id=two>some in-flow text
</div>
<p id=three>some in-flow text

有两个流外元素——HTML 元素和 DIV 元素。 HTML 元素的“流”是它本身、BODY 元素以及#one 和#three;如果您遍历其中每一个的祖先树,它们遇到的第一个流外元素就是 HTML 元素。

DIV 有它自己的流程,由它自己和#two 组成,因为当你遍历#two 的祖先链时,你先访问了 DIV,然后才访问了 HTML。

粗略地说,元素的“流”是在布局中协同工作的一组事物。流外元素(及其后代)大多独立布局。

这个概念并不是很有用,不过 - 别担心。

关于css - 在 CSS 视觉格式模型中, "the flow of an element"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40325236/

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