Styl agtergrond Aanhegsel eiendom
Voorbeeld
Stel 'n agtergrondprent om reg te stel (sal nie blaai nie):
document.body.style.backgroundAttachment = "fixed";
Meer "Probeer dit self" voorbeelde hieronder.
Definisie en gebruik
Die backgroundAttachment-eienskap stel of gee terug of 'n agtergrondprent saam met die inhoud moet blaai, of reggemaak moet word.
Blaaierondersteuning
Die nommers in die tabel spesifiseer die eerste blaaierweergawe wat die eiendom ten volle ondersteun.
Property | |||||
---|---|---|---|---|---|
backgroundAttachment | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Sintaksis
Gee die agtergrondAttachment-eienskap terug:
object.style.backgroundAttachment
Stel die agtergrondAttachment-eienskap:
object.style.backgroundAttachment = "scroll|fixed|local|initial|inherit"
Eiendomswaardes
Value | Description |
---|---|
scroll | The background scrolls along with the element. This is default |
fixed | The background is fixed with regard to the viewport |
local | The background scrolls along with the element's contents |
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: | blaai |
---|---|
Terugkeerwaarde: | 'n String, wat verteenwoordig hoe die agtergrondprent aan die voorwerp binne die dokument geheg word |
CSS weergawe | CSS1 |
Meer voorbeelde
Voorbeeld
Kies tussen blaai en plaaslik op 'n DIV-element:
document.getElementById("myDIV").style.backgroundAttachment = "local";
Voorbeeld
Wissel tussen blaai en vasgestel:
var x = document.body.style.backgroundAttachment;
document.body.style.backgroundAttachment = (x == "scroll")? "fixed":"scroll";
Voorbeeld
Gee die waarde van die agtergrond-aanhegsel-eienskap terug:
alert(document.body.style.backgroundAttachment);
Verwante bladsye
CSS-tutoriaal: CSS-agtergrond
CSS verwysing: agtergrond-aanhegsel eiendom
HTML DOM verwysing: agtergrond eiendom