css - Normal Flow、Flow Layout、Block 和 Inline Layout 有什么区别?

标签 css

都是同义词吗?

使用这些术语的网站示例:

The outermost element in a document that uses block layout rules establishes the first, or initial block formatting context. This means that every element inside the element's block is laid out according to normal flow following the rules for block and inline layout. (source: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flow_Layout/Intro_to_formatting_contexts#block_formatting_contexts)

我不明白“使用 block 布局规则”部分。 “ block 布局”的定义是什么?

The element lays out its contents using flow layout (block-and-inline layout). (source: https://www.w3.org/TR/css-display-3/#flow-layout)

到底什么是流式布局、 block 式和内联式布局?

Boxes in the normal flow belong to a formatting context, which may be block or inline, but not both simultaneously. Block-level boxes participate in a block formatting context. Inline-level boxes participate in an inline formatting context. (source: https://www.w3.org/TR/CSS2/visuren.html#normal-flow)

这里它讨论了它的行为方式,但没有确切说明它是什么。

也许正常流 = 流式布局 = block-and-inline = block-layout = inline-layout?

最佳答案

正常流 = 流布局 = block 和内联。

block 布局≠内联布局

CSS2 描述 block layout :

In a block formatting context, boxes are laid out one after the other, vertically², beginning at the top of a containing block.

inline layout :

In an inline formatting context, boxes are laid out horizontally², one after the other, beginning at the top of a containing block.

那里有更多细节¹,但这是布局的本质。

“正常流”的目的是提供一个单独的布局术语,以与 float 和定位布局以及其他独立格式化上下文的内部结构进行对比。


¹ 几乎整个 CSS 2.2 规范的第 9 节到第 16 节都在描述这个细节。

² 这里的“垂直”和“水平”假定为水平书写模式。 CSS 3 引入了垂直书写模式,其中所有内容都旋转了 90°,因此“垂直”和“水平”颠倒了。

关于css - Normal Flow、Flow Layout、Block 和 Inline Layout 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72581483/

相关文章:

html - ul li 最后一个元素对齐

javascript - 修改输入 float 标签脚本以也适用于文本区域

css - radio 输入(按钮)开关/切换样式不适用于 IE

javascript - 滑动组件?

c++ - WebKit CSS 3d 转换在 Snow Leopard 中不起作用

css - 当我将屏幕旋转为横向时,移动 CSS 不起作用

CSS 2 Div 布局 float

css - @Html.Textbox 和 glyphicon 之间的空格

javascript - 动态调整高度

javascript - 检测浏览器当前 "media"模式