blob: 66dfda684513412e54dc42086b14a7fd936f22bc (
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
|
---
title: <length-percentage>
slug: Web/CSS/length-percentage
translation_of: Web/CSS/length-percentage
---
<div>{{CSSRef}}</div>
<p>The <strong><code><length-percentage></code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> <a href="/en-US/docs/Web/CSS/CSS_Types">data type</a> represents a value that can be either a {{Cssxref("length")}} or a {{Cssxref("percentage")}}.<br>
The <strong><code><length-percentage> </code></strong>CSS数据类型表示一个值,该值可以是<length>或<percentage>。</p>
<h2 id="Syntax">Syntax</h2>
<p>Refer to the documentation for {{Cssxref("length")}} and {{Cssxref("percentage")}} for details of the individual syntaxes allowed by this type.</p>
<h2 id="Use_in_calc()">Use in <code>calc()</code></h2>
<p>Where a <code><length-percentage></code> is specified as an allowable type, this means that the percentage resolves to a length and therefore can be used in a {{cssxref("calc", "calc()")}} expression. Therefore, all of the following values are acceptable for {{cssxref("width")}}:</p>
<pre class="syntaxbox example-good">width: 200px;
width: 20%;
width: calc(100% - 200px);
</pre>
<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 Values', '#mixed-percentages', '<length-percentage>')}}</td>
<td>{{Spec2('CSS4 Values')}}</td>
<td></td>
</tr>
<tr>
<td>{{SpecName('CSS3 Values', '#mixed-percentages', '<length-percentage>')}}</td>
<td>{{Spec2('CSS3 Values')}}</td>
<td>Defines <code><length-percentage></code>. Adds <code>calc()</code></td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("css.types.length-percentage")}}</p>
|