0

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.pngbutton@2x.pngどちらも images フォルダにあります。LESS ファイルに正しくリンクしていない可能性があると思いますが、修正方法がわかりません。

ありがとう

4

1 に答える 1

0

問題は、LESS コンパイラ スクリプトがないことです (seven-phases-max で提案されているように)。

htmlの修正は次のとおりです。

<head>
<link rel="stylesheet/less" href="../../scripts/retina-1.1.0.less" type="text/css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.7.0/less.min.js" ></script>
</head>
于 2014-03-25T06:59:24.787 に答える