J'essaie de mélanger background-imageet de background-sizepropriétés dans une propriété en sténographie background. Basé sur la documentation du W3C, il background-size doit venir après la background-positionpropriété séparée par une barre oblique ( /).
Exemple W3C:
p { background: url("chess.png") 40% / 10em gray round fixed border-box; }est équivalent à:
p { background-color: gray; background-position: 40% 50%; background-size: 10em 10em; background-repeat: round round; background-clip: border-box; background-origin: border-box; background-attachment: fixed; background-image: url(chess.png) }
MDN dit la même chose. J'ai également trouvé ceci et cet article sur la propriété d'arrière-plan CSS3 abrégée expliquant cela.
Mais ça ne fonctionne pas! Il n'est pas non plus clair comment créer une backgroundpropriété abrégée quand background-sizeet background-positionavoir deux valeurs différentes pour background-position-xet background-position-you la même chose pour background-size. On ne sait pas comment /se déroule la barre oblique ( )? Cet exemple ne fonctionne pas dans mon Chrome 15.
Exemple que j'ai essayé de faire un raccourci est ce code CSS:
div {
background: url(http://www.placedog.com/125/125)
0 0 / 150px 100px
repeat no-repeat
fixed border-box padding-box blue;
height: 300px;
width:360px;
border: 10px dashed magenta;
}
Un exemple plus propre
Cela fonctionne ( JSFiddle )
body{
background-image:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png);
background-position:200px 100px;
background-size:600px 400px;
background-repeat:no-repeat;
}
Cela ne fonctionne pas ( jsfiddle )
body{
background:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png) 200px 100px/600px 400px no-repeat;
}
Cela ne fonctionne pas trop ( jsfiddle )
body{
background:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png) 200px/400px 100px/600px no-repeat;
}