Jiang-Xuan / blog

个人博客
1 stars 0 forks source link

CSS Display Module Level 3 双语译文 #5

Open Jiang-Xuan opened 4 years ago

Jiang-Xuan commented 4 years ago

https://www.w3.org/TR/css-display-3/

Jiang-Xuan commented 4 years ago

原文

Introduction

译文

介绍

原文

CSS takes a source document, organized as a tree of elements and text nodes, and renders it onto a canvas (such as your screen, a piece of paper, or an audio stream). To do this, it generates an intermediary structure, the box tree, which represents the formatting structure of the rendered document. Each box in the box tree represents its corresponding element (or pseudo-element) in space and/or time on the canvas, while each text run in the box tree likewise represents the contents of its corresponding [text nodes]().

译文

CSS 将源文档组织成 elementtext node 状结构, 并将其呈现在画布上(例如屏幕, 一张纸或音频流). 为此, 它将生成一个中间结构, 即 Box 树, 它表示呈现的文档的格式结构. Box 树中的每一个 Box 代表其在画布上的空间 和/或 时间上的对应的元素(或者伪元素). Box 树中的每一个 text run 同样表示其对应的 text nodes 的内容.

原文

To create the box tree, CSS first uses cascading and inheritance, to assign a computed value for each CSS property to each element and text node in the source tree. (See [CSS3-CASCADE].)

译文

为了创建 Box 树, CSS 首先使用级联和继承, 将每个 CSS 属性的计算值分配给源树中的每一个 elementtext node. (参见: [CSS3 CASCADE])

原文

Then, for each element, CSS generates zero or more boxes as specified by that element’s 'display' property. Typically, an element generates a single box, the principal box, which represents itself and contains its contents in the box tree. However, some display values (e.g. display: list-item) generate more than one box (e.g. a principal block box and a child marker box). And some values (such as 'none' or 'contents') cause the element and/or its descendants to not generate any boxes at all. Boxes are often referred to by their display type—e.g. a box generated by an element with display: block is called a “block box” or just a “block”.

译文

然后, 对于每一个 element, CSS 都会生成零个或多个由该 element 的 'display' 属性指定的 Box. 通常, 一个 element 生成一个 Box, 即 principle box(主体 Box), 该 Box 表示自身和其在 Box 树 中包含的内容. 但是, 某些 'display' 值(例如: ['display: list-item']()) 生成超过一个的 Box (例如: 一个 principle block box 和一个子 marker box). 并且某些值(例如: 'none''contents') 导致元素 和/或 其子代完全不生成任何 Box. Box 通常以其 display 类型 来指代, 例如由具有 ['display: block' ]() 的元素生成的 Box 称为 "block box" 或者简称为 "block".

原文

A box is assigned the same styles as its generating element, unless otherwise indicated. In general, inherited properties are assigned to the principal box, and then inherit through the box tree to any other boxes generated by the same element. Non-inherited properties default to applying to the principal box, but when the element generates multiple boxes, are sometimes defined to apply to a different box: for example, the 'border' properties applied to a table element are applied to its table grid box, not to its principal table wrapper box. If the value computation process alters the styles of those boxes, and the element’s style is requested (such as through getComputedStyle()), the element reflects, for each property, the value from the box to which that property was applied.

译文

除非另有指明, Box 被指定与生成其的 element 相同的样式. 通常, 继承的属性分配给 principal box, 然后通过 box 树继承到同一 element 生成的其他任何 Box. 非继承属性默认赋给 principal box, 但是当 element 生成多个 box 时, 有时会定义为适用于其他 Box: 例如, 应用于 table element 的 'border' 属性应用于其 table grid box, 而不是其的 principal table wrapper box. 如果值计算过程更改了这些 box 的样式, 并且请求了 element 的样式(比如通过 getComputedStyle()), 则该元素针对每个属性反应该属性所应用到 Box 的值.

原文

Similarly, each contiguous sequence of sibling text nodes generates a text run containing their text contents, which is assigned the same styles as the generating text nodes. If the sequence contains no text, however, it does not generate a text run.

译文

相似的, 每一个连续的兄弟 text node 序列会生成一个 text run 包含他们的文字内容, 该 text run 的样式与生成的 text node 有相同的样式. 但是, 如果序列不包含文字, 就不会生成 text run.

原文

In constructing the box tree, boxes generated by an element are descendants of the principal box of any ancestor elements. In the general case, the direct parent box of an element’s principal box is the principal box of its nearest ancestor element that generates a box; however, there are some exceptions, such as for 'run-in' boxes, display types (like tables) that generate multiple container boxes, and intervening anonymous boxes.

译文

在构建 Box 树时, 由 element 生成的 box 是任何祖先 element 生成的 principal box 的后代. 在一般情况下, element 的 principal box 的直接 父 Box 是其最接近的祖先 element 生成的 box; 但是, 也有一些例外, 例如 'run-in' box, 生成多个包含 box 的 display 类型(比如 table), 和介入的 anonymous box.

原文

An anonymous box is a box that is not associated with any element. Anonymous boxes are generated in certain circumstances to fix up the box tree when it requires a particular nested structure that is not provided by the boxes generated from the element tree. For example, a table cell box requires a particular type of parent box (the table row box), and will generate an anonymous table row box around itself if its parent is not a table row box. (See [CSS2] § 17.2.1.) Unlike element-generated boxes, whose styles inherit strictly through the element tree, anonymous boxes (which only exist in the box tree) inherit through their box tree parentage.

译文

anonymous box 是不与任何元素相关联的 box. 当 box tree 需要一个特定的嵌套结构时, 但是这个结构没有被从 element tree 生成的 box 提供, anonymous box 就会在这个特定的场景下生成来修补 box tree. 例如, 一个 table cell box 需要一个特定类型的父 box(table row box), 如果其父级不是一个 table row box 将会生成一个 anonymous table row box 来包住它. 和 element 生成的 Box 不同, element 生成的 box 的样式严格通过 element 树继承, anonymous box (只存在于 box 树中) 通过它在 box tree 的出生点进行 继承.

原文

In the course of layout, boxes and text runs can be broken into multiple fragments. This happens, for example, when an inline box and/or text run is broken across lines, or when a block box is broken across pages or columns, in a process called fragmentation. It can also happen due to bidi reordering of text (see Applying the Bidirectional Reorderign Algorithm in CSS Writing Modes) or higher-level display type box splitting, e.g. block-in-inline splitting (see CSS2§9.2) or column-spanner-in-block splitting (see CSS Multi-column Layout). A box therefore consists of one or more box fragments, and a text run consists of one or more text fragments. See [CSS3-BREAK] for more information on fragmentation.

Note: Many of the CSS specs were written before this terminology was ironed out, or refer to things incorrectly, so view older specs with caution when they’re using these terms. It should be possible to infer from context which term they really mean. Please report errors in specs when you find them, so they can be corrected.

Note: Further information on the “aural” box tree and its interaction with the display property can be found in the CSS Speech Module. [CSS-SPEECH-1]

译文

在 layout 的过程中, boxtext run 可以分为多个fragment. 例如, 在称为 fragmentation 的过程中, 当一个 inline box 和/或 text run 跨行中断时, 或者是当一个 block box 跨页/列中断时, 就会发生. 也可能由于文本的 bidi 重排(另见 CSS Writing Modes 中的 Applying the Bidirectional Reorderign Algorithm)或者更高级的 display type box 拆分, 例如 block-in-inline 拆分(见 CSS2§9.2) 或 column-spanner-in-block 拆分(见 CSS Multi-column Layout). 因此, 一个 Box 有一个或者多个 box fragment 组成, 而 text run 有一个或多个 text fragment 组成. 有关更多的 fragmentation 的信息, 见 [CSS3-BREAK].

备注: 许多 CSS 规范是在该术语解决之前书写的, 可能引用错误, 所以在看旧规范使用这些术语的时候, 小心. 应该有可能从上下文中推断出术语的真实含义. 在你在规范中发现他们的时候请 汇报错误

备注: 更多关于 “aural” box tree 的信息和它和 'display' 属性的交互可以在 CSS Speech Module 中找到. [CSS-SPEECH-1]

Jiang-Xuan commented 4 years ago

2. Box Layout Modes: 'display' 属性

原文

image

User Agents are expected to support this property on all media, including non-visual ones.

译文

key value
Name: 'display'
Value: [\ || \] | \ | \ | \ | \
Initial: inline
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: see prose in a variety of specs
Canonical order: per grammer
Animation type: not animatable

用户代理被期望在所有的媒体上支持该属性, 包括非可视媒体.

原文

The 'display' property defines an element’s display type, which consists of the two basic qualities of how an element generates boxes:

Text runs have no display type.

Some 'display' values have additional side-effects: such as 'list-item', which also generates a '::marker' pseudo-element, and 'none', which causes the element’s entire subtree to be left out of the box tree.

Advisement:

The 'display' property has no effect on an element’s semantics: these are defined by the document language and are not affected by CSS. Aside from the 'none' value, which also affects the aural/speech output [CSS-SPEECH-1] and interactivity of an element and its descendants, the 'display' property only affects visual layout: its purpose is to allow designers freedom to change the layout behavior of an element without affecting the underlying document semantics.

译文

'display' 属性定义了一个 element 的 display type, 其由 element 如何生成 box 的两种基本特征组成:

Text runs 没有 display 类型.

一些 'display' 值有额外的副作用: 比如 'list-item', 其也会生成一个 '::marker' pseudo-element, 再比如 'none', 其导致 element 的整个 subtree 从 box tree 中被剔除.

Advisement:

'display' 属性对于 element 的语义没有任何影响: 其通过 document 语言 定义, 并且不会被 CSS 所影响. 除了 'none' 值以外, 其也会影响 aural/speech 输出[CSS-SPEECH-1]和 element 和其后代的交互性, 'display' 属性只影响视觉布局: 其目的是允许设计师自由的去更改 element 的布局行为, 而不用去影响底层的文档语义.

原文

Values are defined as follows:

\ = block | inline | run-in \ = flow | flow-root | table | flex | grid | ruby \ = \? && [ flow | flow-root ]? && list-item \ = table-row-group | table-header-group | table-footer-group | table-row | table-cell | table-column-group | table-column | table-caption | ruby-base | ruby-text | ruby-base-container | ruby-text-container \ = contents | none \ = inline-block | inline-table | inline-flex | inline-grid

译文

值定义如下:

\ = block | inline | run-in \ = flow | flow-root | table | flex | grid | ruby \ = \? && [ flow | flow-root ]? && list-item \ = table-row-group | table-header-group | table-footer-group | table-row | table-cell | table-column-group | table-column | table-caption | ruby-base | ruby-text | ruby-base-container | ruby-text-container \ = contents | none \ = inline-block | inline-table | inline-flex | inline-grid

原文

The following informative table summarizes the values of 'display':

Short 'display' Full 'display' Generate box
'none' - subtree omitted from box tree
'content' - element replaced by contents in box tree
'block' 'block flow' block-level block container aka block box
'flow-root' 'block flow-root' block-level block container that establishes a new block formatting context (BFC)
'inline' 'inline flow' inline box
'inline-block' 'inline flow-root' inline-level block container
'run-in' 'run-in flow' run-in box (inline box with special box-tree-munging rules)
'list-item' 'block flow list-item' block box with additional marker box
'inline list-item' 'inline flow list-item' inline box with additional marker box
'flex' 'block flex' block-level flex container
'inline-flex' 'inline flex' inline-level flex container
'grid' 'block grid' block-level grid container
'inline-grid' 'inline grid' inline-level grid container
'ruby' 'inline ruby' inline-level ruby container
'block ruby' 'block ruby' block box containing ruby container
'table' 'block table' block-level table wrapper box containing table grid box
'inline-table' 'inline table' inline-level table wrapper box containing table grid box
\ types - layout-specific internal box

Note: Following the precedence rules of “most backwards-compatible, then shortest”, serialization of equivalent display values uses the “Short display” column. [CSSOM]

译文

下面的信息表总结了 'display' 值:

Short 'display' Full 'display' Generate box
'none' - subtree omitted from box tree
'content' - element replaced by contents in box tree
'block' 'block flow' block-level block container aka block box
'flow-root' 'block flow-root' block-level block container that establishes a new block formatting context (BFC)
'inline' 'inline flow' inline box
'inline-block' 'inline flow-root' inline-level block container
'run-in' 'run-in flow' run-in box (inline box with special box-tree-munging rules)
'list-item' 'block flow list-item' block box with additional marker box
'inline list-item' 'inline flow list-item' inline box with additional marker box
'flex' 'block flex' block-level flex container
'inline-flex' 'inline flex' inline-level flex container
'grid' 'block grid' block-level grid container
'inline-grid' 'inline grid' inline-level grid container
'ruby' 'inline ruby' inline-level ruby container
'block ruby' 'block ruby' block box containing ruby container
'table' 'block table' block-level table wrapper box containing table grid box
'inline-table' 'inline table' inline-level table wrapper box containing table grid box
\ types - layout-specific internal box

Note: 遵循 "最向后兼容, 然后最短", 使用 "Short display" 列来序列化等值的的 display 值. [CSSOM] Following the precedence rules of “most backwards-compatible, then shortest”, serialization of equivalent display values uses the “Short display” column. [CSSOM]

原文

2.1. Outer Display Roles for Flow Layout: the 'block', 'inline', and 'run-in' keywords

译文

2.1 flow 布局的外层显示角色: 'block', 'inline''run-in' 关键词

原文

The keywords specify the element’s outer display type, which is essentially its principal box’s role in flow layout. They are defined as follows:

The element generates a box that is block-level when placed in flow layout. [CSS2]


The element generates a box that is inline-level when placed in flow layout.


The element generates an run-in box, which is a type of inline-level box with special behavior that attempts to merge it into a subsequent block container. See § 3 Run-In Layout for details.


If a \ value is specified but \ is omitted, the element’s inner display type defaults to 'flow'.

译文

\ 关键词指定 element 的 outer display type, 本质上是 element 的 principal boxflow layout 中的角色. 他们定义如下:

当放置在 flow layout 中时, element 生成一个 block-level 的 box. [CSS2]


当放置在 flow layout 中时, element 生成一个 inline-level 的 box. [CSS2]


element 生成一个 run-in box, 其类型是一个有特殊行为的 inline-level box, 其尝试去合并进随后的 block container. 细节见 § 3 Run-In Layout.


如果指定了 \ 值但是省略了 \, element 的 inner display type 默认是 'flow'.

原文

2.2 Inner Display Layout Models: the 'flow', 'flow-root', 'table', 'flex', 'grid', and 'ruby' keywords

译文

2.2 内部显示布局模型: 'flow', 'flow-root', 'table', 'flex', 'grid', 'ruby' 关键词

原文

The \ keywords specify the element’s inner display type, which defines the type of formatting context that lays out its contents (assuming it is a non-replaced element). They are defined as follows:

The element lays out its contents using flow layout (block-and-inline layout). If its outer display type is 'inline' or 'run-in', and it is participating in a block or inline formatting context, then it generates an inline box.

Otherwise it generates a block container box.

Depending on the value of other properties (such as 'position', 'float', or 'overflow') and whether it is itself participating in a block or inline formatting context, it either establishes a new block formatting context for its contents or integrates its contents into its parent formatting context. See CSS2.1 Chapter 9. [CSS2] A block container that establishes a new block formatting context is considered to have a used inner display type of 'flow-root'.


The element generates a block container box, and lays out its contents using flow layout. It always establishes a new block formatting context for its contents. [CSS2]


The element generates a principal table wrapper box that establishes a block formatting context, and which contains an additionally-generated table grid box that establishes a table formatting context. [CSS2]


The element generates a principal flex container box and establishes a flex formatting context. [CSS3-FLEXBOX]


The element generates a principal grid container box, and establishes a grid formatting context. [CSS3-GRID-LAYOUT]


The element generates a ruby container box and establishes a ruby formatting context in addition to integrating its base-level contents into its parent formatting context (if it is inline) or generating a wrapper box of the appropriate outer display type (if it is not). [CSS3RUBY]


译文

\ 关键词指定 element 的 inner display type, 其定义了布置其内容的 formatting context 的类型(假设其是一个 non-replaced element). 他们定义如下:

element 使用 flow layout(block-and-inline layout) 布置其内容.

如果 outer display type'inline''run-in', 并且其参与 blockinline formatting context, 然后其生成一个 inline box.

除此之外, 其生成一个 block container box.

依赖其他属性的值(如 'position', 'float', 或 'overflow') 和 其自身是否参与 block 或 inline formatting context, 其要不为其内容建立一个新的 block formatting context, 要不将其内容集成到其的父 formatting context. 见 CSS2.1 Chapter 9. [CSS2] 一个 block container 建立一个新的 block formatting context 被认为使用 inner display type'flow-root'.


element 生成一个 block container box, 并且使用 flow layout 布置其内容. 其总是为其内容建立一个新的 block formatting context.


element 生成一个 principal table wrapper box, 其建立一个 block formatting context, 并且其包含一个额外生成的 table grid box, 其建立一个 table formatting context. [CSS2]


element 生成一个 principal flex container box, 并且建立一个 flex formatting context. [CSS3-FLEXBOX]


element 生成一个 principal grid container box, 并且建立一个 grid formatting context. [CSS3-GRID-LAYOUT]


element 生成一个 principal ruby container box, 并且建立一个 ruby formatting context


如果 \ 值指定但是 \ 省略, element 的默认 outer display type 是 'block' -- 除 'ruby'外, 其默认是 'inline'.

原文

2.3 Generating Marker Boxes: the 'list-item' keyword

译文

2.3 生成 Marker Boxes: 'list-item' 关键词

原文

The 'list-item' keyword causes the element to generate a '::marker' pseudo-element [CSS-PSEUDO-4] with the content specified by its 'list-style' properties (CSS 2.1§12.5 Lists) [CSS2] together with a principal box of the specified type for its own contents.

If no inner display type value is specified, the principal box’s inner display type defaults to 'flow'. If no outer display type value is specified, the principal box’s outer display type defaults to 'block'.

Note: Note: In this level, as restricted in the grammar, list-items are limited to the Flow Layout display types ('block'/'inline'/'run-in' with 'flow'/'flow-root' inner types). This restriction may be relaxed in a future level of this module.

译文

'list-item' 关键词使 element 生成一个拥有通过其 'list-style' 指定的内容的 '::maker' pseudo-element [CSS-PSEUDO-4] 和 为其自己的内容生成指定类型的 principal box.

如果没有指定 inner display type 值, principal box 的 inner display type 默认为 'flow'. 如果没有指定 outer display type 值, principal box 的 outer display type 默认为 'block'.

Notes: Note: 在此级别中, 如语法所限制, list-items 仅限于 Flow Layout display 类型 ('block'/'inline'/'run-in' 和 'flow'/'flow-root' inner 类型). 该限制可能在该模块的未来级别中被放宽.

原文

2.4. Layout-Internal Display Types: the 'table-' and 'ruby-' keywords

译文

2.4 布局内部的 Display 类型: 'table-' 和 'ruby-' 关键词

原文

Some layout models, such as 'table' and 'ruby', have a complex internal structure, with several different roles that their children and descendants can fill. This section defines those “layout-internal'display' values, which only have meaning within that particular layout mode.

Unless otherwise specified, both the inner display type and the outer display type of elements using these 'display' values are set to the given keyword.

The \ keywords are defined as follows:

The element is an internal table element. It generates the appropriate internal table box which participates in a table formatting context. See CSS2§17.2 [CSS2].

'table-cell' boxes have a 'flow-root' inner display type.


The element generates a table caption box, which is a block box with special behavior with respect to table and table wrapper boxes. See CSS2§17.2 [CSS2].

'table-caption' boxes have a 'flow-root' 'inner display type'.


The element is an internal ruby element. It generates the appropriate internal ruby box which participates in a ruby formatting context. [CSS3RUBY]

'ruby-base' and 'ruby-text' have a 'flow' inner display type.


Boxes with layout-specific display types generate anonymous wrapper boxes around themselves when placed in an incompatible parent, as defined by their respective specifications.

Example:

For example, Table Layout requires that a 'table-cell' box must have a 'table-row' parent box. If it is misparented, like so:

<div style="display:block;">
  <div style="display:table-cell">...</div>
</div>

It will generate wrapper boxes around itself, producing a structure like:

block box
└anonymous table box
 └anonymous table-row-group box
  └anonymous table-row box
   └table-cell box

Even if the parent is another internal table element, if it’s not the correct one, wrapper boxes will be generated. For example, in the following markup:

<div style="display:table;">
  <div style="display:table-row">
    <div style="display:table-cell">...</div>
  </div>
</div>

Anonymous wrapper box generation will produce:

table box
└anonymous table-row-group box
 └table-row box
  └table-cell box

This "fix-up" ensures that table layout has a predictable structure to operate on.

译文

一些布局模型, 比如 'table''ruby', 有着复杂的内部结构, 其子代和后代可以担当有几种不同的角色. 该部分定义了这些 "layout-internal" 'display' 值, 其只有在特定的布局模式下才有意义.

除非另有规定, 使用这些 'display' 值的 element 的 inner display typeouter display type 均设置为给定关键词.

\ 关键词定义如下:

element 是一个 internal table element. 其生成相应的参与 table formatting context 的 internal table box. 见 CSS2§17.2 [CSS2].

'table-cell' box 有 'flow-root' inner display type.


element 生成一个 table caption box, 其实一个对 table 和 table wrapper box 有特殊行为的 block box. 见 CSS2§17.2 [CSS2].

'table-caption' boxes 有 'flow-root' inner display type.


element 是一个 internal ruby element. 其生成相应的参与 ruby formatting contextinternal ruby box. [CSS3RUBY]

'ruby-base' and 'ruby-text''flow' inner display type.


当被放置在不兼容的父级下时, 有着 layout 特定的 display 类型会生成 anonymous wrapper box 包裹自己, 如其各自的规范所定义.

Example:

例如, table 布局需要 一个 'table-cell' box 必须有一个 'table-row' 父级 box. 如果是缺失父级的, 像如此:

<div style="display:block;">
  <div style="display:table-cell">...</div>
</div>

其会生成 wrapper box 包裹自己, 产生一个像这样的结构:

block box
└anonymous table box
 └anonymous table-row-group box
  └anonymous table-row box
   └table-cell box

即便是父层是另一个 internal table element, 如果其不是正确的那一个, wrapper box 就会被生成. 例如, 在下面的标记:

<div style="display:table;">
  <div style="display:table-row">
    <div style="display:table-cell">...</div>
  </div>
</div>

anonymous wrapper box 生成将会产生:

table box
└anonymous table-row-group box
 └table-row box
  └table-cell box

这种 "修复" 确保表布局具有可预测的结构以进行操作.

Jiang-Xuan commented 4 years ago

原文

2.5. Box Generation: the 'none' and 'contents' keywords

译文

2.5 box 生成: 'none''contents' 关键词

原文

While 'display' can control the types of boxes an element will generate, it can also control whether an element will generate any boxes at all.

The '\' keywords are defined as follows:

The element itself does not generate any boxes, but its children and pseudo-elements still generate boxes and text runs as normal. For the purposes of box generation and layout, the element must be treated as if it had been replaced in the element tree by its contents (including both its source-document children and its pseudo-elements, such as ::before and ::after pseudo-elements, which are generated before/after the element’s children as normal).

Note:

Note: As only the box tree is affected, any semantics based on the document tree, such as selector-matching, event handling, and property inheritance, are not affected. As of writing, however, this is not implemented correctly in major browsers, so using this feature on the Web must be done with care as it can prevent accessibility tools from accessing the element’s semantics.

This value computes to 'display: none' on replaced elements and other elements whose rendering is not entirely controlled by CSS; see Appendix B: Effects of display: contents on Unusual Elements for details.

Note:

Note: Replaced elements and form controls are treated specially because removing only the element’s own generating box is a more-or-less undefined operation. As this behavior may be refined if use cases (and more precise rendering models) develop, authors should use 'display: none' rather than 'display: contents' on such elements for forward-compatibility.


The element and its descendants generate no boxes or text runs.

Similarly, if a text node is defined to behave as display: none, it generates no text runs.


Elements with either of these values do not have inner or outer display types, because they don’t generate any boxes at all.

Note:

Note: As these values cause affected elements to not generate a box, anonymous box generation rules will ignore the elided elements entirely, as if they did not exist in the box tree.

Markup-based relationships, however, are not affected by these values, as they are solely rendering-time effects. For example, although they may affect which table cell appears in a column, they do not affect which table cell is associated with a particular column element. Similarly, they cannot affect which HTML \

element is associated with a particular table or whether a \ is considered to be labelling the contents of a particular \
.

译文

'display' 在控制 element 生成的 box 的类型的同时, 其也可以控制 element 是否总是生成 box.

\ 关键词定义如下:

  • 'contents'

element 自身不会生成任何 box, 但是其 children 和 pseudo-element 仍然像通常一样的生成 boxtext run. 为了 box 的生成和布局, element 必须被认为其在 element tree 中被其内容所取代(同时包括在 source-document children 和其的 pseudo-element, 比如 '::before''::after' pseudo-element, 其正常的生成在 element children 的 之前/之后).

Note:

因为只有 box tree 被影响, 基于 document tree 的任何语义化, 比如 selector-matching, event handling 和 property inheritance 不会被影响. 但是, 至这篇文章写作之时, 在主流浏览器上都没有被正确的实现, 所以在 Web 上使用该特性时必须小心, 因为其可以阻止辅助工具访问 element 的语义.

在 replaced element 和 渲染没有被 CSS 完全控制的其他 element 上, 该值计算为 'display: none'; 细节见 Appendix B: Effects of display: contents on Unusual Elements.

Note:

Note: 对 replaced element 和 表单元素的处理很特别, 因为仅仅移除 element 自己生成的 box 是一个或多或少未定义的操作. 如果用户用例(和更精细的渲染模型) 得以开发, 该行为可能得以改善, 为了 forward-compatibility(向前兼容) 作者应该在这些 element 上使用 'display: none' 而不是 'display: contents'.

  • 'none'

element 和 其后代不生成 boxtext run.

相似的, 如果一个 text node 被定义为行为是 'display: none', 其不生成 text run.


有着这两个值之一的 element 没有 innerouter display type, 因为它们总是不生成任何 box.

Note:

因为这些值导致受影响的 element 不生成 box, anonymous box 生成规则将完全忽略被删除的 element, 就像它们不存在 box tree 中一样.

但是 markup-based 关系, 不被这些值所影响, 因为它们仅仅是渲染时的影响. 例如, 虽然它们可能影响哪一个 table cell 出现在 column 中, 但是它们并不影响哪个 table cell 与特定的 column element 相关联. 相似的, 它们不能影响哪个 HTML \

元素与特定的 table 相关联或是否一个 \ 被认为正在标识特定的 \
的内容.

Jiang-Xuan commented 4 years ago

原文

2.6. Precomposed Inline-level Display Values

译文

2.6 之前合成的 Inline-level display 值

原文

CSS level 2 used a single-keyword syntax for 'display', requiring separate keywords for block-level and inline-level variants of the same layout mode. These \ keywords map as follows:

Behaves as 'inline flow-root'.


Behaves as 'inline table'.


Behaves as 'inline flex'.


Behaves as 'inline grid'.


译文

CSS level 对于 'display' 使用单关键词语法, 对于同一种布局模式的 block-level 和 inline-level 变体需要使用单独的关键词. 这些 \ 关键词映射如下:

表现为 'inline flow-root'.


表现为 'inline table'.


表现为 'inline flex'.


表现为 'inline grid'.


Jiang-Xuan commented 4 years ago

原文

2.7. Automatic Box Type Transformations

译文

2.7 自动的 box 类型转换

原文

Some layout effects require blockification or inlinification of the box type, which sets the box’s outer display type to 'block' or 'inline' (respectively). (This has no effect on display types that generate no box at all, such as 'none' or 'contents'.) Additionally:

Note:

Note: There are two methods used to fix up box types when a box is mismatched to its context. One is transformation of the computed value of 'display', such as blockification and inlinification described here. The other, taking place during box tree construction (after computed values have been determined), is the creation of intermediary anonymous boxes, such as happens in tables, ruby, and flow layout.

Example 2

Some examples of computed-value fixup include:

The root element’s display type is always blockified. Additionally, a 'display' of 'contents' computes to 'block' on the root element.

译文

某些布局效果需要对 box 类型进行 blockificationinlinification, 其设置 box 的 outer display type'block''inline' (各自的). (这对总是不生成 box 的 display type 没有效果, 比如 'none''contents'.) 另外:

Note:

Note: 当一个 box 不匹配其上下文时, 这里存在两种办法被用来修复 box 的类型. 一个是转换 'display'computed value, 比如这里所说的 blockificationinlinification. 另一个, 发生在 box tree 构建 的过程中(在 computed value 被确定之后), 是中间的 anonymous box 的创建, 比如在 table, ruby, flow 布局中发生的.

Example 2

一些 computed-value 修复的例子包括:

root element 的 display 总是被 blockifie, 另外, 在 root element 上, 'display''contents' 被计算成 'block'.