以下は、sass/compassを使用してbase64インラインイメージを生成します。
background-image:inline-image("paper.jpg", 'image/jpg');
複数の背景画像を作成する方法はありますか、それとも自分で事前圧縮する必要がありますか?
ありがとう。
以下は、sass/compassを使用してbase64インラインイメージを生成します。
background-image:inline-image("paper.jpg", 'image/jpg');
複数の背景画像を作成する方法はありますか、それとも自分で事前圧縮する必要がありますか?
ありがとう。
inline-image 関数は url() 文字列を出力するだけなので、これを行うことで複数を使用できます。
background: inline-image("front-image.jpg", 'image/jpg') no-repeat, inline-image("back-image.jpg", 'image/jpg') repeat-x
そして、次の css を取得します。
background: url('data:"image/jpg";base64,FRONTIMAGEDATAHERE') no-repeat, url('data:"image/jpg";base64,BACKIMAGEDATAHERE') repeat-x;
「no-repeat」と「repeat-x」を追加しました。そうしないと、前面の画像が繰り返され、背面の画像が覆われます。
私はsenchatouch2を使用していて、これに次のsass拡張機能を見つけました:
theme_images.rb:
module SenchaTouch
module SassExtensions
module Functions
module ThemeImages
def theme_image(theme, path, mime_type = nil)
path = path.value
images_path = File.join(File.dirname(__FILE__), "..", "images", theme.value)
real_path = File.join(images_path, path)
inline_image_string(data(real_path), compute_mime_type(path, mime_type))
end
end
end
end
end
module Sass::Script::Functions
include SenchaTouch::SassExtensions::Functions::ThemeImages
end
compass_init.rb:
# This file registers the sencha-touch framework with compass
# It's a magic name that compass knows how to find.
dir = File.dirname(__FILE__)
require File.join(dir, 'lib', 'theme_images.rb')
Compass::Frameworks.register 'sencha-touch', dir
使用法を参照してください:
background: theme_image($theme-name, "clear_icon.png") no-repeat;
-webkit-mask: theme_image($theme-name, "select_mask.png");
-webkit-mask-image: theme_image($theme-name, "pictos/arrow_down.png");