Esempio
Impostare un background-image da fissare (will not scroll) :
document.body.style.backgroundAttachment = "fixed";
Prova tu stesso " Più "Try it Yourself" esempi di seguito.
Definizione e l'utilizzo
Gli insiemi di proprietà backgroundAttachment o ritorni se un'immagine di sfondo dovrebbero scorrere con il contenuto, o di essere risolto.
Supporto browser
I numeri nella tabella indicano la prima versione del browser che supporta pienamente la proprietà.
Proprietà | |||||
---|---|---|---|---|---|
backgroundAttachment | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Sintassi
Restituire la proprietà backgroundAttachment:
object .style.backgroundAttachment
Impostare la proprietà backgroundAttachment:
object .style.backgroundAttachment="scroll|fixed|local|initial|inherit"
I valori delle proprietà
Valore | Descrizione |
---|---|
scroll | I rotoli di fondo insieme con l'elemento. Questa è l'impostazione predefinita |
fixed | Lo sfondo è fissato per quanto riguarda la finestra |
local | I rotoli di fondo insieme con il contenuto dell'elemento |
initial | Consente di impostare questa proprietà al suo valore di default. Leggi iniziale |
inherit | Eredita questo immobile dal suo elemento genitore. Leggi su erediterà |
Dettagli tecnici
Valore di default: | scorrere |
---|---|
Valore di ritorno: | A String, che rappresenta come l'immagine di sfondo è collegato all'oggetto all'interno del documento |
CSS Version | CSS1 |
Altri esempi
Esempio
Scegliere tra scorrimento e locale su un elemento DIV:
document.getElementById("myDIV").style.backgroundAttachment = "local";
Prova tu stesso " Esempio
Alternare tra scorrimento e fisso:
var x = document.body.style.backgroundAttachment;
document.body.style.backgroundAttachment=(x=="scroll")? "fixed":"scroll";
Prova tu stesso " Esempio
Restituisce il valore della proprietà background-attachment:
alert(document.body.style.backgroundAttachment);
Prova tu stesso " Pagine correlate
CSS tutorial: Sfondo CSS
Di riferimento CSS: background-attachment property
Di riferimento HTML DOM: background property
<Stile di oggetto