Styl teksBelyn eiendom
Voorbeeld
Sentreer-belyn die teks in 'n element:
document.getElementById("demo").style.textAlign = "center";
Definisie en gebruik
Die textAlign-eienskap stel of gee die horisontale belyning van teks in 'n blokvlakelement terug.
Blaaierondersteuning
Property | |||||
---|---|---|---|---|---|
textAlign | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Gee die textAlign-eienskap terug:
object.style.textAlign
Stel die textAlign-eienskap:
object.style.textAlign = "left|right|center|justify|initial|inherit"
Eiendomswaardes
Value | Description |
---|---|
left | Aligns the text to the left. This is default |
right | Aligns the text to the right |
center | Centers the text |
justify | The text is justified |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Tegniese besonderhede
Standaard waarde: | links |
---|---|
Terugkeerwaarde: | 'n String, wat die horisontale belyning van teks binne die element voorstel |
CSS weergawe | CSS1 |
Meer voorbeelde
Voorbeeld
Gee die teksbelyning van 'n element terug:
alert(document.getElementById("demo").style.textAlign);
Verwante bladsye
CSS-tutoriaal: CSS-teks
CSS-verwysing: teksbelyn-eienskap
❮ Stylvoorwerp