Propriété CSS background-origin
Exemple
Laissez l'image de fond commencer à partir du coin supérieur gauche du contenu :
#example1 {
border: 10px dashed black;
padding:
25px;
background: url(paper.gif);
background-repeat: no-repeat;
background-origin:
content-box;
}
Plus d'exemples "Essayez-le vous-même" ci-dessous.
Définition et utilisation
La background-origin
propriété spécifie la position d'origine (la zone de positionnement d'arrière-plan) d'une image d'arrière-plan.
Remarque : Cette propriété n'a aucun effet si background-attachment est "fixed".
Valeur par défaut: | boîte de rembourrage |
---|---|
Hérité: | non |
Animable : | non. En savoir plus sur l'animation |
Version: | CSS3 |
Syntaxe JavaScript : | objet .style.backgroundOrigin="content-box" |
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 | |||||
---|---|---|---|---|---|
background-origin | 4.0 | 9.0 | 4.0 | 3.0 | 10.5 |
Syntaxe CSS
background-origin: padding-box|border-box|content-box|initial|inherit;
Valeurs de propriété
Value | Description | Play it |
---|---|---|
padding-box | Default value. The background image starts from the upper left corner of the padding edge | |
border-box | The background image starts from the upper left corner of the border | |
content-box | The background image starts from the upper left corner of the content | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Plus d'exemples
Exemple
Définissez deux images d'arrière-plan pour un élément <div>. Laissez l'image d'arrière-plan "paper.gif" commencer à partir du coin supérieur gauche du bord de remplissage et laissez l'image d'arrière-plan "img_tree.gif" commencer à partir du coin supérieur gauche du contenu :
#example1 {
border: 10px dashed black;
padding: 25px;
background: url(img_tree.gif), url(paper.gif);
background-repeat: no-repeat;
background-origin:
content-box, padding-box;
}
Pages connexes
Tutoriel CSS : Arrière-plans CSS
Référence HTML DOM : propriété backgroundOrigin