1

$image-widthプロパティにand$image-height引数を使用する際に問題がありbackground-sizeます。CSS は、引数を所定の位置に記述することを選択した場合にのみ機能します (以下のコード例のコメント行に見られるように)。動的バージョンは機能しません。私が間違っていることは何ですか?

それに加えて、このコード スニペットは、デバイスで必要な場合にのみ Retina バージョンをロードする必要があります。詳細については、メディア クエリ アセットのダウンロードをご覧ください。

/* 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;
    }
}
4

1 に答える 1

0

はい、コードは正常に機能しています。呼び出し元の関数の引数に「px」を割り当てるのを忘れました。したがって、結果のCSSは間違っていました(単位なし)。なんて役に立たない間違い。どうもありがとう!

于 2012-07-24T09:39:30.393 に答える