Propriété de style backgroundRepeat
Exemple
Définissez une image d'arrière-plan sur no-repeat :
document.body.style.backgroundRepeat = "repeat-y";
Plus d'exemples "Essayez-le vous-même" ci-dessous.
Définition et utilisation
La propriété backgroundRepeat définit ou renvoie comment répéter (mosaïque) une image d'arrière-plan.
Prise en charge du navigateur
Les nombres dans le tableau indiquent la première version du navigateur qui prend entièrement en charge la propriété.
Property | |||||
---|---|---|---|---|---|
backgroundRepeat | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Syntaxe
Renvoyez la propriété backgroundRepeat :
object.style.backgroundRepeat
Définissez la propriété backgroundRepeat :
object.style.backgroundRepeat = "repeat|repeat-x|repeat-y|no-repeat|initial|inherit"
Valeurs de propriété
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 |
Détails techniques
Valeur par défaut: | répéter |
---|---|
Valeur de retour : | Une chaîne, représentant la façon dont une image d'arrière-plan est répétée |
Version CSS | CSS1 |
Plus d'exemples
Exemple
Modifiez la propriété backgroundRepeat d'un élément DIV spécifié :
document.getElementById("myDIV").style.backgroundRepeat = "repeat-x";
Exemple
Définissez une image d'arrière-plan à répéter horizontalement ou verticalement :
function repeatVer()
{
document.body.style.backgroundRepeat = "repeat-y";
}
function repeatHor() {
document.body.style.backgroundRepeat = "repeat-x";
}
Exemple
Renvoie la valeur background-repeat d'un document :
alert(document.body.style.backgroundRepeat);
Pages connexes
Tutoriel CSS : Arrière-plan CSS
Référence CSS : propriété background-position
Référence CSS : propriété background-repeat
Référence HTML DOM : propriété background