Propriété CSS text-align-last
Exemple
Alignez la dernière ligne de texte dans trois éléments <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;
}
Plus d'exemples "Essayez-le vous-même" ci-dessous.
Définition et utilisation
La text-align-last
propriété spécifie comment aligner la dernière ligne d'un texte.
Notez que la text-align-last
propriété définit l'alignement de toutes les dernières lignes de l'élément sélectionné. Donc, si vous avez un <div> avec trois paragraphes, text-align-last
s'appliquera à la dernière ligne de CHACUN des paragraphes. Pour n'utiliser text-align-last
que le dernier paragraphe du conteneur, vous pouvez utiliser :last child, voir l'exemple ci-dessous.
Remarque : dans Edge antérieur à 79, la text-align-last
propriété ne fonctionne que sur le texte qui contient "text-align : justifier".
Valeur par défaut: | auto |
---|---|
Hérité: | Oui |
Animable : | non. En savoir plus sur l'animation |
Version: | CSS3 |
Syntaxe JavaScript : | objet .style.textAlignLast="right" |
Prise en charge du navigateur
Les nombres dans le tableau indiquent la première version du navigateur qui prend entièrement en charge la propriété.
Les nombres suivis de -moz- spécifient la première version qui a fonctionné avec un préfixe.
Property | |||||
---|---|---|---|---|---|
text-align-last | 47.0 | 5.5* | 49.0 12.0 -moz- |
Not supported | 34.0 |
*Dans Internet Explorer 11 (et versions antérieures), les valeurs "début" et "fin" ne sont pas prises en charge.
Syntaxe CSS
text-align-last: auto|left|right|center|justify|start|end|initial|inherit;
Valeurs de propriété
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 |
Plus d'exemples
Exemple
Utilisez text-align-last uniquement sur la toute dernière ligne du conteneur :
div.b p:last-child {
text-align-last: center;
}
Pages connexes
Tutoriel CSS : Texte CSS
Référence HTML DOM : propriété textAlignLast