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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
---
title: vertical-align
slug: Web/CSS/vertical-align
tags:
- CSS
- Propriedades CSS
- Referencia
translation_of: Web/CSS/vertical-align
---
<div>{{CSSRef}}</div>
<p>A propriedade <strong><code>vertical-align</code></strong> do <a href="/en-US/docs/Web/CSS">CSS</a> especifica o alinhamento vertical de um inline ou caixa table-cell.</p>
<pre class="brush: css no-line-numbers">/* keyword values */
vertical-align: baseline;
vertical-align: sub;
vertical-align: super;
vertical-align: text-top;
vertical-align: text-bottom;
vertical-align: middle;
vertical-align: top;
vertical-align: bottom;
/* <length> values */
vertical-align: 10em;
vertical-align: 4px;
/* <percentage> values */
vertical-align: 20%;
/* Global values */
vertical-align: inherit;
vertical-align: initial;
vertical-align: unset;
</pre>
<p>A propriedade vertical-align pode ser usada em dois contextos:</p>
<ul>
<li>Para alinhar verticalmente uma caixa de elementos inline dentro dentro de sua caixa de linha. Por exemplo, poderia ser usado para alinhar verticalmente um {{HTMLElement("img")}} em uma linha de texto:</li>
</ul>
<div id="vertical-align-inline">
<pre class="hidden brush: html"><p>
top:<img style="vertical-align:top" src="https://mdn.mozillademos.org/files/15189/star.png"/>
middle:<img style="vertical-align:middle" src="https://mdn.mozillademos.org/files/15189/star.png"/>
bottom:<img style="vertical-align:bottom" src="https://mdn.mozillademos.org/files/15189/star.png"/>
super:<img style="vertical-align:super" src="https://mdn.mozillademos.org/files/15189/star.png"/>
sub:<img style="vertical-align:sub" src="https://mdn.mozillademos.org/files/15189/star.png"/>
</p>
<p>
text-top:<img style="vertical-align:text-top" src="https://mdn.mozillademos.org/files/15189/star.png"/>
text-bottom:<img style="vertical-align:text-bottom" src="https://mdn.mozillademos.org/files/15189/star.png"/>
0.2em:<img style="vertical-align:0.2em" src="https://mdn.mozillademos.org/files/15189/star.png"/>
-1em:<img style="vertical-align:-1em" src="https://mdn.mozillademos.org/files/15189/star.png"/>
20%:<img style="vertical-align:20%" src="https://mdn.mozillademos.org/files/15189/star.png"/>
-100%:<img style="vertical-align:-100%" src="https://mdn.mozillademos.org/files/15189/star.png"/>
</p>
</pre>
<pre class="hidden brush: css">#* {
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>Para alinhar verticalmente o conteudo de uma celula em uma tabela:</li>
</ul>
<div id="vertical-align-table">
<pre class="hidden brush: html"><table>
<tr>
<td style="vertical-align: baseline">baseline</td>
<td style="vertical-align: top">top</td>
<td style="vertical-align: middle">middle</td>
<td style="vertical-align: bottom">bottom</td>
<td>
<p>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.</p>
<p>There is another theory which states that this has already happened.</p>
</td>
</tr>
</table>
</pre>
<pre class="hidden brush: css">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>Observe que <code>vertical-align</code> é aplicado apenas em elementos inline e table-cell: Você não pode usar isso para alinhar verticalmente elementos de nível de bloco.</p>
<p>{{cssinfo}}</p>
<h2 id="Sintaxe">Sintaxe</h2>
<p>This property is specified as one of the keyword values listed below.</p>
<h3 id="Valores_para_elementos_inline">Valores para elementos inline</h3>
<p><em>Most of the values vertically align the element relative to its parent element:<br>
Essas propriedades alinham verticalmente o elemento relativamente a seu elemento pai</em></p>
<dl>
<dt><code>baseline</code></dt>
<dd>Aligns the baseline of the element with the baseline of its parent. The baseline of some <a href="/en-US/docs/Web/CSS/Replaced_element">replaced elements</a>, like {{HTMLElement("textarea")}}, is not specified by the HTML specification, meaning that their behavior with this keyword may change from one browser to the other.</dd>
<dt><code>sub</code></dt>
<dd>Aligns the baseline of the element with the subscript-baseline of its parent.</dd>
<dt><code>super</code></dt>
<dd>Aligns the baseline of the element with the superscript-baseline of its parent.</dd>
<dt><code>text-top</code></dt>
<dd>Aligns the top of the element with the top of the parent element's font.</dd>
<dt><code>text-bottom</code></dt>
<dd>Aligns the bottom of the element with the bottom of the parent element's font.</dd>
<dt><code>middle</code></dt>
<dd>Aligns the middle of the element with the baseline plus half the x-height of the parent.</dd>
<dt>{{cssxref("<length>")}}</dt>
<dd>Aligns the baseline of the element at the given length above the baseline of its parent.</dd>
<dt>{{cssxref("<percentage>")}}</dt>
<dd>Like <length> values, with the percentage being a percent of the {{Cssxref("line-height")}} property.</dd>
</dl>
<p>(Negative values are allowed for <length> and <percentage>.)</p>
<p><em>The following two values vertically align the element relative to the entire line rather than relative to its parent:</em></p>
<dl>
<dt><code>top</code></dt>
<dd>Align the top of the element and its descendants with the top of the entire line.</dd>
<dt><code>bottom</code></dt>
<dd>Align the bottom of the element and its descendants with the bottom of the entire line.</dd>
</dl>
<p>For elements that do not have a baseline, the bottom margin edge is used instead.</p>
<h3 id="Values_(for_table_cells)">Values (for table cells)</h3>
<dl>
<dt><code>baseline</code> (and <code>sub</code>, <code>super</code>, <code>text-top</code>, <code>text-bottom</code>, <code><length></code>, and <code><percentage></code>)</dt>
<dd>Align the baseline of the cell with the baseline of all other cells in the row that are baseline-aligned.</dd>
<dt><code>top</code></dt>
<dd>Align the top padding edge of the cell with the top of the row.</dd>
<dt><code>middle</code></dt>
<dd>Center the padding box of the cell within the row.</dd>
<dt><code>bottom</code></dt>
<dd>Align the bottom padding edge of the cell with the bottom of the row.</dd>
</dl>
<p>Negative values are allowed.</p>
<h3 id="Formal_syntax">Formal syntax</h3>
{{csssyntax}}
<h2 id="Exemplo">Exemplo</h2>
<h3 id="HTML">HTML</h3>
<pre class="brush: html"><div>An <img src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /> image with a default alignment.</div>
<div>An <img class="top" src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /> image with a text-top alignment.</div>
<div>An <img class="bottom" src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /> image with a text-bottom alignment.</div>
<div>An <img class="middle" src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /> image with a middle alignment.</div>
</pre>
<h3 id="CSS">CSS</h3>
<pre class="brush: css">img.top { vertical-align: text-top; }
img.bottom { vertical-align: text-bottom; }
img.middle { vertical-align: middle; }
</pre>
<h3 id="Output">Output</h3>
<p>{{EmbedLiveSample("Example")}}<br>
</p>
<h2 id="Especificações">Especificações</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('CSS3 Transitions', '#animatable-css', 'vertical-align')}}</td>
<td>{{Spec2('CSS3 Transitions')}}</td>
<td>Defines <code>vertical-align</code> as animatable.</td>
</tr>
<tr>
<td>{{SpecName('CSS2.1', 'visudet.html#propdef-vertical-align', 'vertical-align')}}</td>
<td>{{Spec2('CSS2.1')}}</td>
<td>Add the {{cssxref("<length>")}} value and allows it to be applied to element with a {{cssxref("display")}} type of <code>table-cell</code>.</td>
</tr>
<tr>
<td>{{SpecName('CSS1', '#vertical-align', 'vertical-align')}}</td>
<td>{{Spec2('CSS1')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Edge</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>1.0</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatGeckoDesktop("1.0")}}</td>
<td>4.0</td>
<td>4.0</td>
<td>1.0 (85)</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Edge</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>1.0</td>
<td>1.0</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatGeckoMobile("1.0")}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>1.0</td>
</tr>
</tbody>
</table>
</div>
<h2 id="Veja_também">Veja também</h2>
<ul>
<li>{{Cssxref("line-height")}}, {{Cssxref("text-align")}}, {{Cssxref("margin")}}</li>
<li><a href="http://phrogz.net/css/vertical-align/index.html">Understanding <code>vertical-align</code>, or "How (Not) To Vertically Center Content"</a></li>
<li><a href="http://christopheraue.net/2014/03/05/vertical-align/">All You Need To Know About Vertical-Align</a></li>
</ul>
|