aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/resize/index.html
blob: 79f318087fba9f1108fc1bb044e8a5ba1493814d (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
---
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>

{{csssyntax}}

<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">&lt;textarea class="example"&gt;Type some text here.&lt;/textarea&gt;</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">&lt;div class="resizable"&gt;
  &lt;p class="resizable"&gt;
    This paragraph is resizable, because the CSS resize property is set to 'both' on this
    element.
  &lt;/p&gt;
&lt;/div&gt;
</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>

{{Compat("css.properties.resize")}}

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

<ul>
 <li>{{HTMLElement("textarea")}}</li>
</ul>