Propriedade CSS text-align-last
Exemplo
Alinhe a última linha de texto em três elementos <div>:
div.a
{
text-align: justify; /* For Edge */
text-align-last: right;
}
div.b
{
text-align: justify; /* For Edge */
text-align-last: center;
}
div.c
{
text-align: justify; /* For Edge */
text-align-last: justify;
}
Mais exemplos de "Experimente você mesmo" abaixo.
Definição e uso
A text-align-last
propriedade especifica como alinhar a última linha de um texto.
Observe que a text-align-last
propriedade define o alinhamento para todas as últimas linhas dentro do elemento selecionado. Então, se você tiver um <div> com três parágrafos nele, text-align-last
será aplicado na última linha de CADA um dos parágrafos. Para usar text-align-last
apenas no último parágrafo do container, você pode usar :last child, veja o exemplo abaixo.
Nota: No Edge anterior a 79, a text-align-last
propriedade só funciona em texto que tenha "text-align: justify".
Valor padrão: | auto |
---|---|
Herdado: | sim |
Animavel: | não. Leia sobre animáveis |
Versão: | CSS3 |
Sintaxe JavaScript: | objeto .style.textAlignLast="right" |
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que oferece suporte total à propriedade.
Números seguidos por -moz- especificam a primeira versão que funcionou com um prefixo.
Property | |||||
---|---|---|---|---|---|
text-align-last | 47.0 | 5.5* | 49.0 12.0 -moz- |
Not supported | 34.0 |
*No Internet Explorer 11 (e anteriores), os valores "start" e "end" não são suportados.
Sintaxe CSS
text-align-last: auto|left|right|center|justify|start|end|initial|inherit;
Valores de propriedade
Value | Description | Play it |
---|---|---|
auto | Default value. The last line is justified and aligned left | |
left | The last line is aligned to the left | |
right | The last line is aligned to the right | |
center | The last line is center-aligned | |
justify | The last line is justified as the rest of the lines | |
start | The last line is aligned at the beginning of the line (left if the text-direction is left-to-right, and right is the text-direction is right-to-left) | |
end | The last line is aligned at the end of the line (right if the text-direction is left-to-right, and left is the text-direction is right-to-left) | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Mais exemplos
Exemplo
Use text-align-last apenas na última linha do contêiner:
div.b p:last-child {
text-align-last: center;
}
Páginas relacionadas
Tutorial CSS: Texto CSS
Referência HTML DOM: propriedade textAlignLast