我在为属性使用$image-width
and$image-height
参数时遇到问题。background-size
CSS 仅在我选择将参数编写到位时才有效(如下面代码示例中的注释行所示)。动态版不行。我做错了什么?
除此之外,此代码片段应仅在设备需要时加载视网膜版本。在此处阅读更多信息:媒体查询资产下载
/* 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;
}
}