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/css/text-indent/index.html | 116 +++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 files/zh-cn/web/css/text-indent/index.html (limited to 'files/zh-cn/web/css/text-indent') diff --git a/files/zh-cn/web/css/text-indent/index.html b/files/zh-cn/web/css/text-indent/index.html new file mode 100644 index 0000000000..75314be041 --- /dev/null +++ b/files/zh-cn/web/css/text-indent/index.html @@ -0,0 +1,116 @@ +--- +title: text-indent +slug: Web/CSS/text-indent +translation_of: Web/CSS/text-indent +--- +
{{CSSRef}}
+ +

text-indent 属性能定义一个块元素首行文本内容之前的缩进量。

+ +
{{EmbedInteractiveExample("pages/css/text-indent.html")}}
+ +

Syntax

+ +
/* <length> 长度值 */
+text-indent: 3mm;
+text-indent: 40px;
+
+/* <percentage>百分比值取决于其包含块(containing block)的宽度*/
+text-indent: 15%;
+
+/* 关键字 */
+text-indent: 5em each-line;
+text-indent: 5em hanging;
+text-indent: 5em hanging each-line;
+
+/* 全局值 */
+text-indent: inherit;
+text-indent: initial;
+text-indent: unset;
+ +

Values

+ +
+
<length>
+
使用固定的<length>值来指定文本的缩进。允许使用负值。查阅可能的 {{cssxref("<length>")}} 单位。
+
<percentage>
+
使用包含块宽度的百分比作为缩进.
+
each-line {{experimental_inline}}
+
文本缩进会影响第一行,以及使用<br>强制断行后的第一行。
+
hanging {{experimental_inline}}
+
该值会对所有的行进行反转缩进:除了第一行之外的所有的行都会被缩进,看起来就像第一行设置了一个负的缩进值。
+
+ +

正式语法

+ +
+
+
{{csssyntax}}
+
+
+
+ +

例子

+ +

HTML

+ +
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
+    nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
+ +

CSS

+ +
p {
+  text-indent: 5em;
+  background: powderblue;
+}
+
+ +

结果

+ +

{{EmbedLiveSample('例子')}}

+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Text', '#text-indent', 'text-indent')}}{{Spec2('CSS3 Text')}}Added the hanging and each-line keywords
{{SpecName('CSS3 Transitions', '#animatable-css', 'text-indent')}}{{Spec2('CSS3 Transitions')}}Lists text-indent as animatable.
{{SpecName('CSS2.1', 'text.html#indentation-prop', 'text-indent')}}{{Spec2('CSS2.1')}}The behavior with display: inline-block and anonymous block boxes have been explicitly defined.
{{SpecName('CSS1', '#text-indent', 'text-indent')}}{{Spec2('CSS1')}}
+ +

{{cssinfo}}

+ +

浏览器兼容性

+ + + +

{{Compat("css.properties.text-indent")}}

+ +
-- cgit v1.2.3-54-g00ecf