我正在尝试使用来自retinajs.com 的retina-1.1.0.less 代码。它不起作用,因为根本没有显示背景图像。
这是html:
<head>
<link rel="stylesheet/less" href="../../scripts/retina-1.1.0.less" type="text/css" />
</head>
这是retina.less:
// retina.less
// A helper mixin for applying high-resolution background images (http://www.retinajs.com)
@highdpi: ~"(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)";
.at2x(@path, @w: auto, @h: auto) {
background-image: url(@path);
@at2x_path: ~`@{path}.replace(/\.\w+$/, function(match) { return "@2x" + match; })`;
@media @highdpi {
background-image: url("@{at2x_path}");
background-size: @w @h;
}
}
#button {
.at2x('images/button.png');
}
这是CSS(不过我认为这并不重要):
#button {
height: 50px;
width: 50px;
float: left;
margin-right: 10px;
}
button.png
并且button@2x.png
都在图像文件夹中。我想我可能没有正确链接到 LESS 文件,但我不知道如何修复它。
谢谢