aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/css/vertical-align/index.html
blob: e401376bca67714e22579243db63d21109d77be9 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
---
title: vertical-align
slug: Web/CSS/vertical-align
tags:
  - CSS
  - CSS Eigenschaft
  - Referenz
  - 'recipe:css-property'
translation_of: Web/CSS/vertical-align
---
<div>{{CSSRef}}</div>

<p>Die <a href="/de/docs/Web/CSS">CSS</a> Eigenschaft <strong><code>vertical-align</code></strong> bestimmt die vertikale Ausrichtung in inline Elementen oder in Tabellenzellen.</p>

<div>{{EmbedInteractiveExample("pages/css/vertical-align.html")}}
<div class="hidden">Die Quelle für dieses interaktive Beispiel ist in einem GitHub-Repository gespeichert. Wenn Sie zum Projekt der interaktiven Beispiele beitragen möchten, klonen Sie bitte <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> und senden Sie uns eine Pull-Anfrage.</div>
</div>

<p>Die vertical-align Eigenschaft kann in zwei Anwendungsfällen genutzt werden:</p>

<ul>
 <li>Um die Box eines inline-Elements vertikal in der beinhaltenden Box auszurichten. Beispielsweise kann sie eingesetzt werden um die ein {{HTMLElement("img")}} in einer Textzeile vertikal auszurichten:</li>
</ul>

<div id="vertical-align-inline">
<pre class="hidden brush: html notranslate">&lt;p&gt;
top:&lt;img style="vertical-align:top" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
middle:&lt;img style="vertical-align:middle" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
bottom:&lt;img style="vertical-align:bottom" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
super:&lt;img style="vertical-align:super" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
sub:&lt;img style="vertical-align:sub" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
&lt;/p&gt;
&lt;p&gt;
text-top:&lt;img style="vertical-align:text-top" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
text-bottom:&lt;img  style="vertical-align:text-bottom" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
0.2em:&lt;img style="vertical-align:0.2em" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
-1em:&lt;img  style="vertical-align:-1em" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
20%:&lt;img style="vertical-align:20%" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
-100%:&lt;img  style="vertical-align:-100%" src="https://mdn.mozillademos.org/files/15189/star.png"/&gt;
&lt;/p&gt;

</pre>

<pre class="hidden brush: css notranslate">#* {
  box-sizing: border-box;
}

img {
  margin-right: 0.5em;
}

p {
  height: 3em;
  padding: 0 .5em;
  font-family: monospace;
  text-decoration: underline overline;
  margin-left: auto;
  margin-right: auto;
  width: 80%;
}
</pre>
</div>

<p>{{EmbedLiveSample("vertical-align-inline", 1200, 120, "", "", "example-outcome-frame")}}</p>

<ul>
 <li>Um den Inhalt einer Zelle vertikal in einer Tabelle auszurichten:</li>
</ul>

<div id="vertical-align-table">
<pre class="hidden brush: html notranslate">&lt;table&gt;
  &lt;tr&gt;
    &lt;td style="vertical-align: baseline"&gt;baseline&lt;/td&gt;
    &lt;td style="vertical-align: top"&gt;top&lt;/td&gt;
    &lt;td style="vertical-align: middle"&gt;middle&lt;/td&gt;
    &lt;td style="vertical-align: bottom"&gt;bottom&lt;/td&gt;
    &lt;td&gt;
      &lt;p&gt;There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.&lt;/p&gt;
&lt;p&gt;There is another theory which states that this has already happened.&lt;/p&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

</pre>

<pre class="hidden brush: css notranslate">table {
  margin-left: auto;
  margin-right: auto;
  width: 80%;
}

table, th, td {
  border: 1px solid black;
}

td {
  padding: 0.5em;
  font-family: monospace;
}
</pre>
</div>

<p>{{EmbedLiveSample("vertical-align-table", 1200, 210, "", "", "example-outcome-frame")}}</p>

<p>Beachte, dass sich <code>vertical-align</code> nur auf inline- und Tabellenzellenelemente bezieht: es kann nicht eingesetzt werden um <a href="/de/docs/Web/HTML/Block-level_elemente">Block-level Elemente</a> auszurichten.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="brush: css no-line-numbers language-css notranslate"><code class="language-css"><span class="comment token">/* Schlüsselwörter */</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> baseline<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> sub<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> super<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> text-top<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> text-bottom<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> middle<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> top<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> bottom<span class="punctuation token">;</span>

<span class="comment token">/* &lt;length&gt; Werte */</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> <span class="number token">10</span>em<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> <span class="number token">4</span>px<span class="punctuation token">;</span>

<span class="comment token">/* &lt;percentage&gt; Werte */</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> <span class="number token">20%</span><span class="punctuation token">;</span>

<span class="comment token">/* Globale Werte */</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> inherit<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> initial<span class="punctuation token">;</span>
<span class="property token">vertical-align</span><span class="punctuation token">:</span> unset<span class="punctuation token">;</span></code></pre>

<p>Bei Elementen, die keine Grundlinie besitzen, beziehen sich die Angaben auf die untere äußere Kante (<em>bottom margin edge</em>).</p>

<h3 id="Werte_für_inline-Elemente">Werte für inline-Elemente</h3>

<dl>
 <dt>
 <h4 id="Eltern-Elemente">Eltern-Elemente</h4>
 </dt>
</dl>

<p>Diese Werte richten das Element vertikal relativ zu seinem übergeordneten Element aus:</p>

<dl>
 <dt><code>baseline</code></dt>
 <dd>Die Grundlinie des Elements liegt auf der Grundlinie des Elternelements.</dd>
 <dt><code>sub</code></dt>
 <dd>Das Element ist tiefgestellt.</dd>
 <dt><code>super</code></dt>
 <dd>Das Element ist hochgestellt.</dd>
 <dt><code>text-top</code></dt>
 <dd>Die Oberkante des Elements liegt auf der Oberkante der Schrift des Elternelements.</dd>
 <dt><code>text-bottom</code></dt>
 <dd>Die Unterkante des Elements liegt auf der Unterkante der Schrift des Elternelements.</dd>
 <dt><code>middle</code></dt>
 <dd>Die Mitte des Elements liegt auf der Mitte der Kleinbuchstaben des Elternelements.</dd>
 <dt><code>top</code></dt>
 <dd>Die Oberkante des Elements liegt auf der Oberkante des Elternelements.</dd>
 <dt><code>bottom</code></dt>
 <dd>Die Unterkante des Elements liegt auf der Unterkante des Elternelements.</dd>
 <dt>{{cssxref("&lt;percentage&gt;")}}</dt>
 <dd>Die Unterkante des Elements liegt um einen <a href="/de/CSS/Einheiten#Prozent">prozentualen Wert</a> höher als die Unterkante des Elternelements. Die Anteile beziehen sich auf den Wert der <a href="/de/CSS/line-height" title="de/CSS/line-height"><code>line-height</code></a> Eigenschaft.</dd>
 <dt>{{cssxref("&lt;length&gt;")}}</dt>
 <dd>Die Unterkante des Elements liegt um einen <a href="/de/CSS/Einheiten#L.c3.a4ngen">bestimmten Wert</a> höher als die Unterkante des Elternelements. Negative Werte sind erlaubt.</dd>
 <dt><code>inherit</code></dt>
 <dd>Der Wert des Elternelements wird geerbt.</dd>
</dl>

<h3 id="Werte_für_Tabellenzellen">Werte für Tabellenzellen</h3>

<dl>
 <dt>baseline, sub, super, text-top, text-bottom, &lt;Prozentzahl&gt; und &lt;Länge&gt;</dt>
 <dd>Die Grundlinie des Elements liegt auf der Grundlinie des Elternelements</dd>
 <dt>top</dt>
 <dd>Die Oberkante der Textzeile liegt auf der Oberkante der Tabellenzelle.</dd>
 <dt>middle</dt>
 <dd>Die vertikale Mitte der Textzeile liegt auf der Mitte der Tabellenzelle.</dd>
 <dt>bottom</dt>
 <dd>Die Unterkante der Textzeile liegt auf der Unterkante der Tabellenzelle.</dd>
 <dt>inherit</dt>
 <dd>Der Wert des Elternelements wird geerbt.</dd>
</dl>

<h3 id="Formale_Syntax">Formale Syntax</h3>

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

<h2 id="Beispiel">Beispiel</h2>

<h3 id="HTML">HTML</h3>

<pre class="brush: html notranslate">&lt;div&gt;Ein &lt;img src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /&gt; Bild mit default Ausrichtung.&lt;/div&gt;
&lt;div&gt;Ein &lt;img class="top" src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /&gt; Bild mit text-top Ausrichtung.&lt;/div&gt;
&lt;div&gt;Ein &lt;img class="bottom" src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /&gt; Bild mit text-bottom Ausrichtung.&lt;/div&gt;
&lt;div&gt;Ein &lt;img class="middle" src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /&gt; Bild mit middle Ausrichtung.&lt;/div&gt;
</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css notranslate">img.top { vertical-align: text-top; }
img.bottom { vertical-align: text-bottom; }
img.middle { vertical-align: middle; }
</pre>

<h3 id="Ergebnis">Ergebnis</h3>

<p>{{EmbedLiveSample("Beispiel")}}</p>

<h2 id="Spezifikation">Spezifikation</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Spezifikation</th>
   <th scope="col">Status</th>
   <th scope="col">Kommentar</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Transitions', '#animatable-css', 'vertical-align')}}</td>
   <td>{{Spec2('CSS3 Transitions')}}</td>
   <td>Definiert<code>vertical-align</code> als animierbar.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'visudet.html#propdef-vertical-align', 'vertical-align')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Fügt den {{cssxref("&lt;length&gt;")}} Wert hinzu und erlaubt die Anwendung auf Elemente mit <code>table-cell </code>{{cssxref("display")}}-Typ.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS1', '#vertical-align', 'vertical-align')}}</td>
   <td>{{Spec2('CSS1')}}</td>
   <td>Einführung.</td>
  </tr>
 </tbody>
</table>

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

<h2 id="Browserkompatibilität">Browserkompatibilität</h2>

<p>{{Compat("css.properties.vertical-align")}}</p>

<h2 id="Siehe_auch">Siehe auch</h2>

<ul>
 <li>{{Cssxref("line-height")}}</li>
 <li>{{Cssxref("text-align")}}</li>
</ul>