常规流中的块和内联布局

常规流中的块和内联布局

块格式区域中的元素

比如在英语环境中,块元素工作于横板书写模式中,此时的块元素会垂直排布,一个在另一个之下。

而在竖版书写模式中,块元素会水平排布。

在本指南的例子中,我们使用的是英语,因此会按横板模式进行书写。不过,即使你的文档是按照竖版模式进行书写的,描述的所有内容也都应该以相同的方式工作。

如规范中所定义,外边距使得两个块级盒子分开。这个例子展示了一个非常简单的由两个段落组成的排版,每个段落都加了一个边框。浏览器的默认样式表通过增加外边距(margin)的方式在每个段落的顶部和底部留出一定空间。

html

One November night in the year 1782, so the story runs, two brothers sat

over their winter fire in the little French town of Annonay, watching the

grey smoke-wreaths from the hearth curl up the wide chimney. Their names

were Stephen and Joseph Montgolfier, they were papermakers by trade, and

were noted as possessing thoughtful minds and a deep interest in all

scientific knowledge and new discovery.

Before that night—a memorable night, as it was to prove—hundreds of millions

of people had watched the rising smoke-wreaths of their fires without

drawing any special inspiration from the fact.

cssp {

border: 2px solid green;

}

如果我们将 p 元素的边距设置为 0,两个边框会紧贴在一起。

html

One November night in the year 1782, so the story runs, two brothers sat

over their winter fire in the little French town of Annonay, watching the

grey smoke-wreaths from the hearth curl up the wide chimney. Their names

were Stephen and Joseph Montgolfier, they were papermakers by trade, and

were noted as possessing thoughtful minds and a deep interest in all

scientific knowledge and new discovery.

Before that night—a memorable night, as it was to prove—hundreds of millions

of people had watched the rising smoke-wreaths of their fires without

drawing any special inspiration from the fact.

cssp {

border: 2px solid green;

margin: 0;

}

默认情况下,块级元素将占据这一内联方向的所有空间,因此我们的段落会铺开分布在多行,尽可能排满他的包含块。如果限定了段落元素的宽度,第二个段落仍然会排布在第一个段落的下面——即使有足够空间使它们并排。每个块级元素都会从包含块的起始边开始,因此,在当前书写模式下,所有句子会从包含块的起始边开始。

html

One November night in the year 1782, so the story runs, two brothers sat

over their winter fire in the little French town of Annonay, watching the

grey smoke-wreaths from the hearth curl up the wide chimney. Their names

were Stephen and Joseph Montgolfier, they were papermakers by trade, and

were noted as possessing thoughtful minds and a deep interest in all

scientific knowledge and new discovery.

Before that night—a memorable night, as it was to prove—hundreds of millions

of people had watched the rising smoke-wreaths of their fires without

drawing any special inspiration from the fact.

cssp {

border: 2px solid green;

width: 40%;

}

相关文章

365现金app下载 黑教皇堡酒庄 Chateau Pape Clement

黑教皇堡酒庄 Chateau Pape Clement

⏱️ 07-04 👁️ 5176
365bet官网开户网址 跖疣常见么?

跖疣常见么?

⏱️ 08-10 👁️ 3877
beat365手机版官方网站正规 办电话卡需要准备什么

办电话卡需要准备什么

⏱️ 08-19 👁️ 4848