2012-03-16 11 views
5

私はアイコンクラスを作成するためにinline-image関数を使用しています。これは私の現在のSCSSです:SCSS - イメージの取得サイズ

.folder { 
    background: inline-image("icons/home/folder.png", 'image/png') no-repeat center; 
    height: 30px; 
    width: 41px; 
} 

私はこのような何かを行うことができますので、画像の幅と高さを決定することができる機能を探しています:

.folder { 
    background: inline-image("icons/home/folder.png", 'image/png') no-repeat center; 
    height: image-height("icons/home/folder.png", 'image/png'); 
    width: image-width("icons/home/folder.png", 'image/png'); 
} 

このようなものは存在していますか?

答えて

8

はあなたが右の関数名を推測しました。このhttp://compass-style.org/reference/compass/helpers/image-dimensions/

を発見しました。

これらを使用するには、コンパスをインストールする必要があります。

それはこのようなものになります:私はアイコンのスプライトを使用することをお勧めいたしますでしょうちなみに

@import "compass/helpers"; 

.folder { 
    background: inline-image("icons/home/folder.png", 'image/png') no-repeat center; 
    height: image-height("icons/home/folder.png"); 
    width: image-width("icons/home/folder.png"); 
} 

http://compass-style.org/reference/compass/helpers/sprites/

+0

ちょうどヘルパー関数をインポートしていませんでした。それは素晴らしいコンパスもスプライトを生成することができます。挑戦的にスプライトに変わるでしょう。助けてくれてありがとう! – sissonb

+0

私は欠けていると信じています。 @import "compass/helpers"の後に。それなしではコンパイルされません。 –

+0

ありがとう@ArthurAlvim – welldan97

関連する問題