// SCSS #logo { @include retina('my_image.png', 3, 100px50px, center center no-repeat); }
// Sass #logo +retina ('my_image.png', 3, 100px50px, center center no-repeat);
// Less #logo { .retina('my_image.png', 3, 100px50px, center center no-repeat); }
// Stylus #logo retina('my_image.png', 3, 100px50px, center center no-repeat);
编译成:
#logo { background: url("my_image.png") center center no-repeat; background-size: 100px50px; }
@media all and (-webkit-min-device-pixel-ratio: 1.5), all and (-o-min-device-pixel-ratio: 3 / 2), all and (min--moz-device-pixel-ratio: 1.5), all and (min-device-pixel-ratio: 1.5) { #item { background: url("my_image@2x.png") center center no-repeat; background-size: 100px50px; } }
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { #item { background: url("my_image@2x.png") center center no-repeat; background-size: 100px50px; } }
@media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 288dpi) { #item { background: url("my_image@3x.png") center center no-repeat; background-size: 100px50px; } }