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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
---
title: resize
slug: Web/CSS/resize
tags:
- resize
- 调整大小
translation_of: Web/CSS/resize
---
<div>{{CSSRef}}</div>
<h2 id="概述">概述</h2>
<p> <strong><code>resize</code></strong> CSS 属性允许你控制一个元素的可调整大小性。</p>
<p>{{cssinfo}}</p>
<h2 id="语法">语法</h2>
<pre class="brush: css">/* Keyword values */
resize: none;
resize: both;
resize: horizontal;
resize: vertical;
resize: block;
resize: inline;
/* Global values */
resize: inherit;
resize: initial;
resize: unset;
</pre>
<h3 id="取值">取值</h3>
<dl>
<dt><code>none</code></dt>
<dd>元素不能被用户缩放。</dd>
<dt><code>both</code></dt>
<dd>允许用户在水平和垂直方向上调整元素的大小。</dd>
<dt><code>horizontal</code></dt>
<dd>允许用户在水平方向上调整元素的大小。</dd>
<dt><code>vertical</code></dt>
<dd>允许用户在垂直方向上调整元素的大小。</dd>
<dt><code>block</code> {{experimental_inline}}</dt>
<dd>Depending on the {{cssxref("writing-mode")}} and {{cssxref("direction")}} value, the element displays a mechanism for allowing the user to resize the element either horizontally or vertically in block direction.</dd>
<dt><code>inline</code> {{experimental_inline}}</dt>
<dd>Depending on the {{cssxref("writing-mode")}} and {{cssxref("direction")}} value, the element displays a mechanism for allowing the user to resize the element either horizontally or vertically in inline direction.</dd>
</dl>
<div class="note"><strong>Note:</strong> 如果一个block元素的 {{cssxref("overflow")}} 属性被设置成了<code>visible</code>,那么<code>resize</code>属性对该元素无效。</div>
<h3 id="标准语法">标准语法</h3>
<pre class="syntaxbox">{{csssyntax}}</pre>
<h2 id="例子">例子</h2>
<h3 id="Disabling_resizability_of_textareas">Disabling resizability of textareas</h3>
<h4 id="CSS">CSS</h4>
<p>{{HTMLElement("textarea")}} 元素在{{gecko("2.0")}} (Firefox 4)中默认是可以进行缩放的. 你可以通过下面的CSS代码来重写这种行为:</p>
<pre class="brush: css">textarea.example {
resize: none; /* disables resizability */
}
</pre>
<h4 id="HTML">HTML</h4>
<pre class="brush: html"><textarea class="example">Type some text here.</textarea></pre>
<h4 id="Result">Result</h4>
<p>{{EmbedLiveSample("Disabling_resizability_of_textareas","200","100")}}</p>
<h3 id="Using_resize_with_arbitrary_elements">Using resize with arbitrary elements</h3>
<p>You can use the resize property to make any element resizable. In the example below, a resizable {{HTMLElement("div")}} box contains a resizable paragraph ({{HTMLElement("p")}} element):</p>
<h4 id="CSS_2">CSS</h4>
<pre class="brush: css">.resizable {
resize: both;
overflow: scroll;
border: 1px solid black;
}
div {
height: 300px;
width: 300px;
}
p {
height: 200px;
width: 200px;
}
</pre>
<h4 id="HTML_2">HTML</h4>
<pre class="brush: html"><div class="resizable">
<p class="resizable">
This paragraph is resizable, because the CSS resize property is set to 'both' on this
element.
</p>
</div>
</pre>
<h4 id="Result_2">Result</h4>
<p>{{EmbedLiveSample("Using_resize_with_arbitrary_elements","450","450")}}</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('CSS Logical Properties', '#resize', 'resize')}}</td>
<td>{{Spec2('CSS Logical Properties')}}</td>
<td>Adds the values <code>block</code> and <code>inline</code>.</td>
</tr>
<tr>
<td>{{SpecName('CSS3 Basic UI', '#resize', 'resize')}}</td>
<td>{{Spec2('CSS3 Basic UI')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div>{{CompatibilityTable}}</div>
<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 (on {{HTMLElement("textarea")}})</td>
<td>1.0</td>
<td>{{CompatGeckoDesktop("2.0")}}{{property_prefix("-moz")}}</td>
<td>{{CompatNo}}</td>
<td>12.1</td>
<td>3.0 (522)</td>
</tr>
<tr>
<td>On any block-level and replaced element, table cell, and inline block element (unless {{cssxref("overflow")}} is <code>visible</code>)</td>
<td>4.0</td>
<td>{{CompatGeckoDesktop("5.0")}}[1]</td>
<td>{{CompatNo}}</td>
<td>15</td>
<td>4.0</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 (on {{HTMLElement("textarea")}})</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
</tr>
<tr>
<td>On any block-level and replaced element, table cell, and inline block element (unless {{cssxref("overflow")}} is <code>visible</code>)</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
</tr>
</tbody>
</table>
</div>
<p>[1] <code>resize</code> doesn't have any effect on {{HTMLElement("iframe")}} (cf. {{bug(680823)}})</p>
<h2 id="See_also">See also</h2>
<ul>
<li>{{HTMLElement("textarea")}}</li>
</ul>
|