Resumen
La propiedad vertical-align de CSS especifica el alineado vertical de un elemento en línea o una celda de una tabla.
| Valor inicial | baseline |
|---|---|
| Applies to | inline-level and table-cell elements. It also applies to ::first-letter and ::first-line. |
| Heredable | no |
| Percentages | refer to the line-height of the element itself |
| Media | visual |
| Valor calculado | for percentage and length values, the absolute length, otherwise the keyword as specified |
| Animatable | yes, as a length |
| Canonical order | el orden único no-ambigüo definido por la gramática formal |
Sintaxis
vertical-align:baseline|sub|super|text-top|text-bottom|middle|top|bottom| <percentage> | <length>
Valores (para elementos en línea)
La mayoría de los valores de alinean verticalmente el elemento de forma relativa al elemento padre:
baseline- Alinea la línea base del elemento con la línea base del padre. La línea base de algunos elementos reemplazados, como
<textarea>no está especificado en la especificación HTML, que significa que su comportamiento puede cambiar en un navegador u otro. sub- Alinea la línea base del elemento con la línea subscript del elemento padre.
super- Alinea la línea base del elemento con la línea superscript del elemento padre.
text-top- Aligns the top of the element with the top of the parent element's font.
text-bottom- Aligns the bottom of the element with the bottom of the parent element's font.
middle- Aligns the middle of the element with the middle of lowercase letters in the parent.
<length>- Aligns the baseline of the element at the given length above the baseline of its parent.
<percentage>- Like <length> values, with the percentage being a percent of the
line-heightproperty.For elements that do not have a baseline, the bottom margin edge is used instead.
However, two values vertically align the element relative to the entire line rather than relative to its parent:
top- Align the top of the element and its descendants with the top of the entire line.
bottom- Align the bottom of the element and its descendants with the bottom of the entire line.
Negative values are allowed.
Valores (para celdas de tablas)
baseline(andsub,super,text-top,text-bottom,<length>, and<percentage>)- Align the baseline of the cell with the baseline of all other cells in the row that are baseline-aligned.
top- Align the top padding edge of the cell with the top of the row.
middle- Center the padding box of the cell within the row.
bottom- Align the bottom padding edge of the cell with the bottom of the row.
Negative values are allowed.
Ejemplos
img {
vertical-align: bottom;
}
Especificaciones
| Specification | Status | Comment |
|---|---|---|
| CSS Transitions The definition of 'vertical-align' in that specification. |
Working Draft | Defines visibility as animatable. |
| CSS Level 2 (Revision 1) The definition of 'vertical-align' in that specification. |
Recommendation | Add the <length> value and allows it to be applied to element with a display type of table-cell. |
| CSS Level 1 The definition of 'vertical-align' in that specification. |
Recommendation | Initial definition. |
Compatibilidad de los navegadores
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 1.0 | 1.0 (1.7 or earlier) | 4.0 | 4.0 | 1.0 (85) |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | 1.0 | 1.0 | 1.0 (1.0) | (Yes) | (Yes) | 1.0 |
Ver también
Etiquetas y colaboradores del documento
Última actualización por:
Sebastianz,