aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/css/length-percentage/index.md
blob: 1ee1b49f6345c7dd839171f3d87ae64b30799be2 (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
---
title: <length-percentage>
slug: Web/CSS/length-percentage
tags:
  - CSS
  - CSS データ型
  - データ型
  - リファレンス
  - length-percentage
  - 単位
  - 値
browser-compat: css.types.length-percentage
translation_of: Web/CSS/length-percentage
---
{{CSSRef}}

**`<length-percentage>`** は [CSS](/ja/docs/Web/CSS) の[データ型](/ja/docs/Web/CSS/CSS_Types)で、 {{Cssxref("length")}} または {{Cssxref("percentage")}} が取りうる値を表します。

## 構文

この型に利用できる個々の構文の詳細は、 {{Cssxref("length")}} および {{Cssxref("percentage")}} の文書を参照してください。

## 例

<h3 id="length-percentage_examples">length-percentage の例</h3>

以下の簡単な例では、`<length-percentage>` の値を使用するいくつかのプロパティを示しています。

#### HTML

```html
<p>パーセント値や長さは様々な場面で使うことができます。</p>
```

#### CSS

```css
p {
  /* length-percentage の例 */
  width: 75%;
  height: 200px;
  margin: 3rem;
  padding: 1%;
  border-radius: 10px 10%;
  font-size: 250%;
  line-height: 1.5em;

  /* length の例 */
  text-shadow: 1px 1px 1px red;
  border: 5px solid red;
  letter-spacing: 3px;

  /* percentage example */
  text-size-adjust: 20%;
}
```

#### 結果

{{EmbedLiveSample('length-percentage_examples', '100%', 320)}}

### calc() での使用

許可されている型として `<length-percentage>` が指定されているところでは、これはパーセント値が長さとして解決されるので、 {{cssxref("calc()")}} の式で利用することができます。したがって、以下のすべての値が {{Cssxref("width")}} で利用できます。

```css example-good
width: 200px;
width: 20%;
width: calc(100% - 200px);
```

## 仕様書

{{Specifications}}

## ブラウザーの互換性

{{Compat}}

## 関連情報

- {{cssxref("&lt;percentage&gt;")}}
- {{cssxref("&lt;length&gt;")}}
- [CSS 値と単位](/ja/docs/Web/CSS/CSS_Values_and_Units)