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/max-height | |
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/max-height')
-rw-r--r-- | files/zh-cn/web/css/max-height/index.html | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/max-height/index.html b/files/zh-cn/web/css/max-height/index.html new file mode 100644 index 0000000000..919ed11b3b --- /dev/null +++ b/files/zh-cn/web/css/max-height/index.html @@ -0,0 +1,117 @@ +--- +title: max-height +slug: Web/CSS/max-height +translation_of: Web/CSS/max-height +--- +<div>{{CSSRef}}</div> + +<p><a href="/en-US/docs/Web/CSS">CSS</a>属性 <strong><code>max-height</code></strong> 设置元素的最大高度。它防止{{cssxref("height")}}属性的使用值(<a href="/en-US/docs/Web/CSS/used_value">used value</a>) 大于 <code>max-height</code> 的指定值。</p> + +<div>{{EmbedInteractiveExample("pages/css/max-height.html")}}</div> + +<div class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</div> + +<p><code>max-height</code> 会覆盖{{cssxref("height")}}, 而{{cssxref("min-height")}} 会覆盖 <code>max-height</code>.</p> + +<h2 id="Syntax" name="Syntax">Syntax</h2> + +<pre class="brush:css no-line-numbers notranslate">/* <length> value */ +max-height: 3.5em; + +/* <percentage> value */ +max-height: 75%; + +/* Keyword values */ +max-height: none; +max-height: max-content; +max-height: min-content; +max-height: fit-content(20em); + +/* Global values */ +max-height: inherit; +max-height: initial; +max-height: unset; +</pre> + +<h3 id="Values" name="Values">Values</h3> + +<dl> + <dt>{{cssxref("<length>")}}</dt> + <dd>Defines the <code>max-height</code> as an absolute value.</dd> + <dt>{{cssxref("<percentage>")}}</dt> + <dd>Defines the <code>max-height</code> as a percentage of the containing block's height.</dd> + <dt><code>auto</code></dt> + <dd>The browser will calculate and select a <code>max-height</code> for the specified element.</dd> + <dt><code>none</code></dt> + <dd>No limit on the size of the box.</dd> + <dt><code>max-content</code></dt> + <dd>The intrinsic preferred <code>max-height</code>.</dd> + <dt><code>min-content</code></dt> + <dd>The intrinsic minimum <code>max-height</code>.</dd> + <dt><code>fit-content({{cssxref("<length-percentage>")}})</code></dt> + <dd>Uses the <code>fit-content</code> formula with the available space replaced by the specified argument, i.e. <code>min(max-content, max(min-content, <var>argument</var>))</code>.</dd> +</dl> + +<h3 id="Formal_syntax">Formal syntax</h3> + +<pre class="syntaxbox notranslate">{{csssyntax}}</pre> + +<h2 id="Examples">Examples</h2> + +<pre class="brush: css notranslate">table { max-height: 75%; } + +form { max-height: none; } +</pre> + +<h2 id="Accessibility_concerns">Accessibility concerns</h2> + +<p>Ensure that elements set with a <code>max-height</code> are not truncated and/or do not obscure other content when the page is zoomed to increase text size.</p> + +<ul> + <li><a href="/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable#Guideline_1.4_Make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background">MDN Understanding WCAG, Guideline 1.4 explanations</a></li> + <li><a href="https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-scale.html" rel="noopener">Understanding Success Criterion 1.4.4 | W3C Understanding WCAG 2.0</a></li> +</ul> + +<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('CSS4 Sizing', '#width-height-keywords', 'max-height')}}</td> + <td>{{Spec2('CSS4 Sizing')}}</td> + <td></td> + </tr> + <tr> + <td>{{SpecName('CSS3 Sizing', '#width-height-keywords', 'max-height')}}</td> + <td>{{Spec2('CSS3 Sizing')}}</td> + <td>Adds the <code>max-content</code>, <code>min-content</code>, <code>fit-content</code> keywords.</td> + </tr> + <tr> + <td>{{SpecName('CSS2.1', 'visudet.html#min-max-heights', 'max-height')}}</td> + <td>{{ Spec2('CSS2.1') }}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<p>{{cssinfo}}</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2> + +<div class="hidden">The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</div> + +<p>{{Compat("css.properties.max-height")}}</p> + +<h2 id="See_also" name="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model" title="en/CSS/box_model">The box model</a>, {{cssxref("box-sizing")}}</li> + <li>{{Cssxref("height")}}, {{Cssxref("min-height")}}</li> +</ul> |