2012-07-23 62 views
1

对于background-size属性,我有问题可以使用$image-width$image-height参数。如果我选择就地编写参数(如下面代码示例中的注释行所示),CSS才起作用。动态版本不起作用。我做错了什么?在这种情况下,Sass/SCSS mixin参数的正确使用是什么?

除此之外,此代码段只能在设备需要时加载视网膜版本。 了解更多关于在这里:​​Media Query Asset Downloading

/* see: http://timkadlec.com/2012/04/media-query-asset-downloading-results/ */ 
@mixin retina-background($filename, $image-width, $image-height, $extension: ".png") { 
    background-image: image-url($filename + $extension); 
    height: $image-height; 
    width: $image-width; 
    @media only screen and (-webkit-min-device-pixel-ratio: 1.5), 
    only screen and (min--moz-device-pixel-ratio: 1.5), 
    only screen and (-o-min-device-pixel-ratio: 3/2), 
    only screen and (min-device-pixel-ratio: 1.5) { 
     background-image: image-url($filename + "2x" + $extension); 
     //background-size: 213px 21px; 
     background-size: $image-width $image-height; 
     height: $image-height; 
     width: $image-width; 
    } 
} 
+0

刚刚检查了你的代码,它工作正常,'background-size'值已经到位。 – Roman 2012-07-24 01:39:15

回答

0

是,代码工作正常。我忘了在我的调用函数的参数中分配“px”。所以产生的CSS是错误的(没有单位)。多么无用的错误。非常感谢!

相关问题