Styl witruimte eiendom
Voorbeeld
Spesifiseer dat die teks in die <div>-element nooit sal omvou nie:
document.getElementById("myDIV").style.whiteSpace = "nowrap";
Definisie en gebruik
Die whiteSpace-eienskap stel of gee terug hoe om oortjies, lynbreuke en witspasie in 'n teks te hanteer.
Blaaierondersteuning
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Gee die whiteSpace-eienskap terug:
object.style.whiteSpace
Stel die whiteSpace-eienskap:
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
Eiendomswaardes
Value | Description |
---|---|
normal | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default |
nowrap | Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a <br> tag is encountered |
pre | Whitespace is preserved by the browser. Text will only wrap on line breaks. Acts like the <pre> tag in HTML |
pre-line | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks |
pre-wrap | Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks |
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: | normaal |
---|---|
Terugkeerwaarde: | 'n String, wat verteenwoordig hoe wit spasie binne 'n element hanteer word |
CSS weergawe | CSS1 |
Meer voorbeelde
Voorbeeld
Gee die whiteSpace-eienskap terug
alert(document.getElementById("myDiv").style.whiteSpace);
Verwante bladsye
CSS-tutoriaal: CSS-teks
CSS verwysing: wit-ruimte eiendom
❮ Stylvoorwerp