2011-08-13 27 views
31

コンパス(CSSフレームワーク)を使用してスプライト画像を生成しています。 これは動作しますが、コンパスは各画像の背景位置のみを生成します。コンパス:スプライトの各画像にスプライトと幅と高さを生成

スプライト内の各画像の幅と高さも取得できますか?

これは私のコードです:

@import "ico/*.png"; 
@include all-ico-sprites; 

生成されたコード:

.ico-sprite, .ico-bag-blue, .ico-bag-black { 
    background: url('../images/ico-s78b1a1919b.png') no-repeat; 
} 

.ico-bag-blue { 
    background-position: 0 0; 
} 

.ico-bag-black { 
    background-position: 0 -24px; 
} 

と私が持っていると思いコード:

.ico-sprite, .ico-bag-blue, .ico-bag-black { 
    background: url('../images/ico-s78b1a1919b.png') no-repeat; 
} 

.ico-bag-blue { 
    background-position: 0 0; 
    width:40px; 
    height:24px; 
} 

.ico-bag-black { 
    background-position: 0 -24px; 
    width:44px; 
    height:30px; 
} 

どのように私誰かが私に説明することができますそれはできますか?おかげさまで

答えて

74

これは動作します
http://compass-style.org/help/tutorials/spriting/

は、あなただけのインポート前に、設定変数を指定します。あなたのケースでは:すべてにtrueを送信

$ico-sprite-dimensions: true; 
@import "ico/*png". 
@include all-ico-sprites; 

の作品が含まれていますが、それは文書化されていないだとして、その設定変数が好ましい方法ですと思われます。それは作品Etienne- @

$<map>-spacing   // space in px around the sprites 
$<map>-repeat   // whether to repeat the sprite bg 
$<map>-position   // the x position of the sprite on the map 
$<map>-sprite-base-class // the base class (default ".<map>-sprite") 
$<map>-clean-up   // whether to delete old image maps 
$<map>-<sprite>-spacing // spacing, for individual sprites 
$<map>-<sprite>-repeat // repeat, for individual sprites 
$<map>-<sprite>-position // position, for individual sprites 
+0

説明をありがとうございます。それは今より明確です。 – Etienne

+0

男、あなたは私の日を救った! – dgilperez

+0

私が何をベースクラスに渡しても、常にエラーがスローされます。この設定オプションは最近壊れているようです。 – Drew

7

解決策が見つかりました。 2番目の引数としてtrueを渡します。

@include all-ico-sprites(true); 

非常に簡単です。

@include all-<map>-sprites(true); 

しかし、あなたは設定変数を使用しての文書化の方法を検討する必要があります:

+0

:寸法は別に

は、これらは、他の設定可能な変数です。ありがとうございました –

関連する問題