aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/text-indent/index.html
blob: f7d4355d3bdafa871297bd5e8bced8c8957404d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
title: text-indent
slug: Web/CSS/text-indent
translation_of: Web/CSS/text-indent
---
<div>{{CSSRef}}</div>

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

<div>{{EmbedInteractiveExample("pages/css/text-indent.html")}}</div>

<h2 id="Syntax">Syntax</h2>

<pre><code>/* &lt;length&gt; 长度值 */
text-indent: 3mm;
text-indent: 40px;

/* &lt;percentage&gt;百分比值取决于其包含块(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;</code></pre>

<h3 id="Values">Values</h3>

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

<h3 id="正式语法">正式语法</h3>

<dl>
 <dt>
 {{csssyntax}}
 </dt>
</dl>

<h2 id="例子">例子</h2>

<h3 id="HTML">HTML</h3>

<pre class="brush: html"><code>&lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
    nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.&lt;/p&gt;</code></pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css"><code>p {
  text-indent: 5em;
  background: powderblue;
}</code>
</pre>

<h3 id="结果">结果</h3>

<p>{{EmbedLiveSample('例子')}}</p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Text', '#text-indent', 'text-indent')}}</td>
   <td>{{Spec2('CSS3 Text')}}</td>
   <td>Added the <code>hanging</code> and <code>each-line</code> keywords</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS3 Transitions', '#animatable-css', 'text-indent')}}</td>
   <td>{{Spec2('CSS3 Transitions')}}</td>
   <td>Lists <code>text-indent</code> as animatable.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'text.html#indentation-prop', 'text-indent')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>The behavior with <code>display: inline-block</code> and anonymous block boxes have been explicitly defined.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS1', '#text-indent', 'text-indent')}}</td>
   <td>{{Spec2('CSS1')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<p>{{cssinfo}}</p>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<div class="hidden">
<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
</div>

<p>{{Compat("css.properties.text-indent")}}</p>

<div id="compat-mobile"></div>