From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/html/element/center/index.html | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 files/zh-cn/web/html/element/center/index.html (limited to 'files/zh-cn/web/html/element/center') diff --git a/files/zh-cn/web/html/element/center/index.html b/files/zh-cn/web/html/element/center/index.html new file mode 100644 index 0000000000..2ccce04ce5 --- /dev/null +++ b/files/zh-cn/web/html/element/center/index.html @@ -0,0 +1,51 @@ +--- +title:
+slug: Web/HTML/Element/center +translation_of: Web/HTML/Element/center +--- +
{{deprecated_header()}}
+ +

Summary

+ +

HTML Center 元素 (<center>) 是个 块级元素,可以包含段落,以及其它块级和内联元素。这个元素的整个内容在它的上级元素中水平居中(通常是 {{HTMLElement("body")}})。

+ +

这个标签已经在 HTML 4(以及 XHTML 1)中废除了,以支持 CSS {{Cssxref("text-align")}} 属性,它可以用于 {{HTMLElement("div")}} 元素,或者独立的 {{HTMLElement("p")}}。对于居中的块,使用其它 CSS 属性,例如 {{Cssxref("margin-left")}} 和 {{Cssxref("margin-right")}},并将其设置为 auto (或者将 {{Cssxref("margin")}} 设为 0 auto).

+ +

DOM 接口

+ +

这个元素实现了 {{domxref("HTMLElement")}} 接口。

+ +
+

实现注解: 直到 Gecko 1.9.2(包含), Firefox 为这个元素实现了 {{domxref("HTMLSpanElement")}} 接口。

+
+ +

示例 1

+ +
<center>This text will be centered.
+<p>So will this paragraph.</p></center>
+
+ +

示例 2 (CSS 替代)

+ +
<div style="text-align:center">This text will be centered.
+<p>So will this paragraph.</p></div>
+
+ +

示例 3 (CSS 替代)

+ +
<p style="text-align:center">This line will be centered.<br>
+And so will this line.</p>
+
+ +

+ +

向 {{HTMLElement("div")}} 或者 {{HTMLElement("p")}} 元素应用 {{Cssxref("text-align")}}:center 会使这些元素的内容居中,同时保留其整体大小不变。

+ +

另见

+ + + +
{{HTMLRef}}
-- cgit v1.2.3-54-g00ecf