CSS规范:块级框,块容器框和块框 [英] CSS Spec: block-level box, block container box and block box

查看:284
本文介绍了CSS规范:块级框,块容器框和块框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 CSS Spec 2.1 ,并发现难以区分的概念:

I am reading CSS Spec 2.1 and find the concepts hard to distinguish:

除了稍后在下一章中介绍的表框和替换元素之外,块级框也是块容器框.块容器框要么仅包含块级框,要么建立内联格式上下文,因此仅包含内嵌级框.并非所有的块容器框都是块级框:不可替换的嵌入式块和不可替换的表格单元格是块容器,但不是块级框.也是块容器的块级框称为块框.

Except for table boxes, which are described in a later chapter, and replaced elements, a block-level box is also a block container box. A block container box either contains only block-level boxes or establishes an inline formatting context and thus contains only inline-level boxes. Not all block container boxes are block-level boxes: non-replaced inline blocks and non-replaced table cells are block containers but not block-level boxes. Block-level boxes that are also block containers are called block boxes.

我可以对以下描述进行解释吗?:

May I interpret the description above as follow?:

推荐答案

您的解释正确.

以下是一些其他详细信息:

Here are some additional details:

  • 表框不是块容器的原因是因为它建立了表布局,而不是块布局.内容进入单元格元素而不是表格元素,这就是为什么 cell 框是块容器而不是表格框本身的原因.

  • The reason a table box is not a block container is because it establishes a table layout, not a block layout. Content goes into the cell elements rather than the table element, which is why it is the cell boxes that are block containers rather than the table box itself.

被替换的元素不包含任何其他内容,因此不能是一个块容器.

A replaced element doesn't contain any other content and therefore cannot be a block container.

块框和内联块之间的唯一区别是,前者是块级的,而后者是内联级的.因此,显示值分别为display: blockdisplay: inline-block.由于两者都是块容器,因此它们的内容格式没有区别.

The only difference between a block box and an inline-block is that the former is block-level while the latter is inline-level. Hence the display values display: block and display: inline-block respectively. As both are block containers, there is no difference in how their contents are formatted.

请注意,替换的元素和表格框可以是内联级别或块级别.内联表和内联替换元素只是从您引用的部分中排除,因为该部分仅与块级框有关;您会在第9节或 10 17 .

Note that replaced elements and table boxes can be either inline-level or block-level. Inline tables and inline replaced elements are simply excluded from the section you quote because that section only pertains to block-level boxes; you'll find references to them elsewhere in section 9, or in sections 10 and 17 respectively.

此外,即使一个块容器框只能包含块级框或行内框,您仍然可以在同一个块容器框中混合使用它们.在内部,它仅通过匿名屏蔽框.

Also, even though a block container box can only either contain block-level boxes or inline-level boxes, you can still mix both in the same block container box; internally it simply segregates the block-level and inline-level boxes via anonymous block boxes.

这篇关于CSS规范:块级框,块容器框和块框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆