Stile di sfondoRipetere la proprietà
Esempio
Imposta un'immagine di sfondo su nessuna ripetizione:
document.body.style.backgroundRepeat = "repeat-y";
Altri esempi "Provalo da solo" di seguito.
Definizione e utilizzo
La proprietà backgroundRepeat imposta o restituisce come ripetere (affiancare) un'immagine di sfondo.
Supporto browser
I numeri nella tabella specificano la prima versione del browser che supporta completamente la proprietà.
Property | |||||
---|---|---|---|---|---|
backgroundRepeat | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Sintassi
Restituisce la proprietà backgroundRepeat:
object.style.backgroundRepeat
Imposta la proprietà backgroundRepeat:
object.style.backgroundRepeat = "repeat|repeat-x|repeat-y|no-repeat|initial|inherit"
Valori di proprietà
Value | Description |
---|---|
repeat | The background image is repeated both vertically and horizontally. This is default |
repeat-x | The background image is only repeated horizontally |
repeat-y | The background image is only repeated vertically |
no-repeat | The background-image is not repeated |
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: | ripetere |
---|---|
Valore di ritorno: | Una stringa, che rappresenta il modo in cui viene ripetuta un'immagine di sfondo |
Versione CSS | CSS1 |
Altri esempi
Esempio
Modificare la proprietà backgroundRepeat di un elemento DIV specificato:
document.getElementById("myDIV").style.backgroundRepeat = "repeat-x";
Esempio
Imposta un'immagine di sfondo da ripetere orizzontalmente o verticalmente:
function repeatVer()
{
document.body.style.backgroundRepeat = "repeat-y";
}
function repeatHor() {
document.body.style.backgroundRepeat = "repeat-x";
}
Esempio
Restituisce il valore di ripetizione in background di un documento:
alert(document.body.style.backgroundRepeat);
Pagine correlate
Tutorial CSS: Sfondo CSS
Riferimento CSS: proprietà posizione di sfondo
Riferimento CSS: proprietà di ripetizione in background
Riferimento HTML DOM: proprietà in background