diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/resize | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/css/resize')
-rw-r--r-- | files/zh-cn/web/css/resize/index.html | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/resize/index.html b/files/zh-cn/web/css/resize/index.html new file mode 100644 index 0000000000..095c57ec78 --- /dev/null +++ b/files/zh-cn/web/css/resize/index.html @@ -0,0 +1,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> |