CSS text-align-last Property
Contoh
Sejajarkan baris teks terakhir dalam tiga elemen <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;
}
Lebih banyak contoh "Coba Sendiri" di bawah ini.
Definisi dan Penggunaan
Properti text-align-last
menentukan cara menyelaraskan baris terakhir teks.
Perhatikan bahwa text-align-last
properti menetapkan perataan untuk semua baris terakhir dalam elemen yang dipilih. Jadi, jika Anda memiliki <div> dengan tiga paragraf di dalamnya, text-align-last
akan berlaku untuk baris terakhir SETIAP paragraf. Untuk menggunakan text-align-last
hanya paragraf terakhir dalam wadah, Anda dapat menggunakan :last child, lihat contoh di bawah.
Catatan: Di Edge sebelum 79, text-align-last
properti hanya berfungsi pada teks yang memiliki "text-align: justify".
Nilai bawaan: | mobil |
---|---|
Diwarisi: | Ya |
Animasi: | tidak. Baca tentang animasi |
Versi: kapan: | CSS3 |
Sintaks JavaScript: | objek .style.textAlignLast="kanan" |
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung properti.
Angka diikuti oleh -moz- menentukan versi pertama yang bekerja dengan awalan.
Property | |||||
---|---|---|---|---|---|
text-align-last | 47.0 | 5.5* | 49.0 12.0 -moz- |
Not supported | 34.0 |
*Di Internet Explorer 11 (dan sebelumnya), nilai "mulai" dan "akhir" tidak didukung.
Sintaks CSS
text-align-last: auto|left|right|center|justify|start|end|initial|inherit;
Nilai properti
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 |
Lebih Banyak Contoh
Contoh
Gunakan text-align-last hanya pada baris terakhir dalam wadah:
div.b p:last-child {
text-align-last: center;
}
Halaman Terkait
Tutorial CSS: Teks CSS
Referensi DOM HTML: properti textAlignLast