aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/min-height/index.html
blob: 29775ae7f59b2f1722f66ccf83570f59bda7b4c0 (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
---
title: min-height
slug: Web/CSS/min-height
translation_of: Web/CSS/min-height
---
<div>{{CSSRef}}</div>

<p>CSS 属性 <code><strong>min-height</strong></code> 能够设置元素的最小高度。这样能够防止 <code>{{cssxref("height")}}</code> 属性的<a href="/zh-CN/docs/Web/CSS/used_value">应用值</a>小于 <code>min-height</code> 的值。</p>

<div>{{EmbedInteractiveExample("pages/css/min-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>min-height</code> 大于 {{cssxref("max-height")}}{{cssxref("height")}} 时,元素的高度会设置为 <code>min-height</code> 的值。</p>

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

<pre class="brush:css no-line-numbers notranslate">/* &lt;长度&gt; 数值 */
min-height: 3.5em;

/* &lt;百分比&gt; 数值 */
min-height: 10%;

/* 关键词 */
min-height: max-content;
min-height: min-content;
min-height: fit-content(20em);

/* 全局数值 */
min-height: inherit;
min-height: initial;
min-height: unset;
</pre>

<h3 id="Values" name="Values">Values</h3>

<dl>
 <dt>{{cssxref("&lt;length&gt;")}}</dt>
 <dd>定义 <code>min-height</code> 为一个绝对数值。</dd>
 <dt>{{cssxref("&lt;percentage&gt;")}}</dt>
 <dd>定义 <code>min-height</code> 为一个相对于父容器高度的百分数。</dd>
 <dt><code>auto</code></dt>
 <dd>浏览器将通过计算为指定元素选择一个 <code>min-height</code> 值。</dd>
 <dt><code>none</code></dt>
 <dd>不限制盒容器的尺寸。</dd>
 <dt><code>max-content</code></dt>
 <dd>The intrinsic preferred <code>min-height</code>.</dd>
 <dt><code>min-content</code></dt>
 <dd>The intrinsic minimum <code>min-height</code>.</dd>
 <dt><code>fit-content({{cssxref("&lt;length-percentage&gt;")}})</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>

<h2 id="Formal_definition">Formal definition</h2>

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

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

<pre class="syntaxbox notranslate">{{csssyntax}}</pre>

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

<h3 id="Setting_min-height">Setting min-height</h3>

<pre class="brush:css; notranslate">table { min-height: 75%; }

form { min-height: 0; }
</pre>

<h2 id="规范">规范</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', 'min-height')}}</td>
   <td>{{Spec2('CSS4 Sizing')}}</td>
   <td></td>
  </tr>
  <tr>
   <td>{{SpecName('CSS3 Sizing', '#width-height-keywords', 'min-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', 'min-height')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("css.properties.min-height")}}</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li><a href="/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model">The box model</a>, {{cssxref("box-sizing")}}</li>
 <li>{{cssxref("height")}}, {{cssxref("max-height")}}</li>
</ul>