当我阅读时the spec,我实际上发现了你的问题回答得很好:
当行内框包含块框时,行内框会在块周围被破坏。中断之前和中断之后的[in]行框包含在匿名框中,并且块框成为这些匿名框的同级框。
<BODY style="display: inline; ">
This is anonymous text before the P.
<P>This is the content of P.</P>
This is anonymous text after the P.
</BODY>
生成的框将是 BODY 周围的匿名块框,包含 C1 周围的匿名块框、P 块框和 C2 周围的另一个匿名块框。
或者,视觉上:
+- anonymous block box around body ---+
| +- anonymous block box around C1 -+ |
| | + |
| +---------------------------------+ |
| |
| +- P block box -------------------+ |
| | + |
| +---------------------------------+ |
| |
| +- anonymous block box around C2 -+ |
| | + |
| +---------------------------------+ |
+-------------------------------------+
现在回答你的问题:这与<BODY style="display: block; ">
?
是的。虽然还是4盒(身体周围的匿名方块现在正在本体块盒),规范告诉区别:
在导致生成匿名块框的元素上设置的属性仍然适用于[生成的匿名块]框和该元素的内容。例如,如果在上例中在 BODY 元素上设置了边框,则边框将围绕 C1(在行尾打开)和 C2(在行首打开)绘制:
+--------------------------------------
| This is anonymous text before the P.
+--------------------------------------
This is the content of P.
--------------------------------------+
This is anonymous text after the P. |
--------------------------------------+
这不同于<BODY style="display: block; ">
:
+--------------------------------------+
| This is anonymous text before the P. |
| |
| This is the content of P. |
| |
| This is anonymous text after the P. |
+--------------------------------------+