CSS text-align-last Właściwość
Przykład
Wyrównaj ostatni wiersz tekstu w trzech elementach <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;
}
Więcej przykładów „Wypróbuj sam” poniżej.
Definicja i użycie
Właściwość text-align-last
określa sposób wyrównania ostatniego wiersza tekstu.
Zauważ, że text-align-last
właściwość ustawia wyrównanie dla wszystkich ostatnich linii w wybranym elemencie. Tak więc, jeśli masz <div> z trzema akapitami, text-align-last
zastosuje się do ostatniego wiersza KAŻDEGO z akapitów. Aby użyć text-align-last
tylko ostatniego akapitu w kontenerze, możesz użyć :last child, patrz przykład poniżej.
Uwaga: W Edge przed 79, text-align-last
właściwość działa tylko na tekście, który ma „text-align: justify”.
Domyślna wartość: | automatyczny |
---|---|
Dziedziczny: | tak |
Animowalny: | nie. Przeczytaj o animacji |
Wersja: | CSS3 |
Składnia JavaScript: | obiekt .style.textAlignLast="prawo" |
Obsługa przeglądarki
Liczby w tabeli określają pierwszą wersję przeglądarki, która w pełni obsługuje tę właściwość.
Liczby, po których następuje -moz- określają pierwszą wersję, która działała z przedrostkiem.
Property | |||||
---|---|---|---|---|---|
text-align-last | 47.0 | 5.5* | 49.0 12.0 -moz- |
Not supported | 34.0 |
*W programie Internet Explorer 11 (i wcześniejszych) wartości „start” i „end” nie są obsługiwane.
Składnia CSS
text-align-last: auto|left|right|center|justify|start|end|initial|inherit;
Wartości nieruchomości
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 |
Więcej przykładów
Przykład
Użyj text-align-last tylko w ostatniej linii w kontenerze:
div.b p:last-child {
text-align-last: center;
}
Powiązane strony
Samouczek CSS: Tekst CSS
Dokumentacja HTML DOM: właściwość textAlignLast