Stile sfondoAttachment Property
Esempio
Imposta un'immagine di sfondo da correggere (non scorrerà):
document.body.style.backgroundAttachment = "fixed";
Altri esempi "Provalo da solo" di seguito.
Definizione e utilizzo
La proprietà backgroundAttachment imposta o restituisce se un'immagine di sfondo deve scorrere con il contenuto o essere corretta.
Supporto browser
I numeri nella tabella specificano la prima versione del browser che supporta completamente la proprietà.
Property | |||||
---|---|---|---|---|---|
backgroundAttachment | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Sintassi
Restituisce la proprietà backgroundAttachment:
object.style.backgroundAttachment
Imposta la proprietà backgroundAttachment:
object.style.backgroundAttachment = "scroll|fixed|local|initial|inherit"
Valori di proprietà
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 |
Dettagli tecnici
Valore di default: | scorrere |
---|---|
Valore di ritorno: | Una stringa, che rappresenta il modo in cui l'immagine di sfondo è allegata all'oggetto all'interno del documento |
Versione CSS | CSS1 |
Altri esempi
Esempio
Scegli tra scroll e local su un elemento DIV:
document.getElementById("myDIV").style.backgroundAttachment = "local";
Esempio
Alterna tra scorrimento e fisso:
var x = document.body.style.backgroundAttachment;
document.body.style.backgroundAttachment = (x == "scroll")? "fixed":"scroll";
Esempio
Restituisce il valore della proprietà background-attachment:
alert(document.body.style.backgroundAttachment);
Pagine correlate
Tutorial CSS: Sfondo CSS
Riferimento CSS: proprietà background-attachment
Riferimento HTML DOM: proprietà in background