aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/list-style-position/index.html
blob: 1b63e9c8b6fbcb7e00d1f0f058a90124f12aff75 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
---
title: list-style-position
slug: Web/CSS/list-style-position
translation_of: Web/CSS/list-style-position
---
<div>{{CSSRef}}</div>

<p> <strong><code>list-style-position</code></strong> 属性指定标记框在主体块框中的位置。</p>

<p>使用助记符{{cssxref("list-style")}}更方便。</p>

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

<h2 id="语法">语法</h2>

<pre class="brush:css notranslate">/* Keyword values */
list-style-position: inside;
list-style-position: outside;

/* Global values */
list-style-position: inherit;
list-style-position: initial;
list-style-position: unset;
</pre>

<h3 id="数值">数值</h3>

<dl>
 <dt><code>outside</code></dt>
 <dd>标记盒在主块盒的外面。</dd>
 <dt><code>inside</code></dt>
 <dd>标记盒是主要块盒中的第一个行内盒,处于元素的内容流之后。</dd>
</dl>

<h3 id="Formal_syntax">Formal syntax</h3>

{{csssyntax}}

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

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

<pre class="brush: html notranslate">&lt;ul class="one"&gt; List 1
  &lt;li&gt;List Item 1-1&lt;/li&gt;
  &lt;li&gt;List Item 1-2&lt;/li&gt;
  &lt;li&gt;List Item 1-3&lt;/li&gt;
  &lt;li&gt;List Item 1-4&lt;/li&gt;
&lt;/ul&gt;
&lt;ul class="two"&gt; List 2
  &lt;li&gt;List Item 2-1&lt;/li&gt;
  &lt;li&gt;List Item 2-2&lt;/li&gt;
  &lt;li&gt;List Item 2-3&lt;/li&gt;
  &lt;li&gt;List Item 2-4&lt;/li&gt;
&lt;/ul&gt;
&lt;ul class="three"&gt; List 3
  &lt;li&gt;List Item 3-1&lt;/li&gt;
  &lt;li&gt;List Item 3-2&lt;/li&gt;
  &lt;li&gt;List Item 3-3&lt;/li&gt;
  &lt;li&gt;List Item 3-4&lt;/li&gt;
&lt;/ul&gt;</pre>

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

<pre class="brush:css; notranslate">.one {
  list-style:square inside;
}

.two {
  list-style-position: outside;
  list-style-type: circle;
}

.three {
  list-style-image: url("https://mdn.mozillademos.org/files/11979/starsolid.gif");
  list-style-position: inherit;
}</pre>

<h3 id="Result">Result</h3>

<p>{{EmbedLiveSample("例子","200","420")}}</p>

<h2 id="Specifications">Specifications</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 Lists', '#list-style-position-property', 'list-style-position')}}</td>
   <td>{{Spec2('CSS3 Lists')}}</td>
   <td>No change.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'generate.html#propdef-list-style-position', 'list-style-position')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>1.0</td>
   <td>1.0 (1.0)</td>
   <td>4.0</td>
   <td>3.5</td>
   <td>1.0 (85)</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>N.B. There is variance among browsers regarding behaviour when a block element is placed first within a list element declared as <code>list-style-position:inside</code>. Chrome and Safari both place this element on the same line as the marker box, whereas Firefox, Internet Explorer and Opera place it on the next line. For more information on this, see this <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=36854">Mozilla Bug</a> report and an <a href="http://jsfiddle.net/hydrurga/MAS7j/">example</a>.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{Cssxref("list-style")}}, {{Cssxref("list-style-type")}}, {{Cssxref("list-style-image")}}</li>
</ul>