Sencha touch 指南针-获取生成的精灵地图的宽度和高度

Sencha touch 指南针-获取生成的精灵地图的宽度和高度,sencha-touch,extjs,sencha-touch-2,sass,compass-sass,Sencha Touch,Extjs,Sencha Touch 2,Sass,Compass Sass,我正在构建一个Sencha Touch移动应用程序,并使用该功能创建带有指南针的图像精灵地图 有没有办法计算图像贴图的大小(宽度和高度)并将其作为变量放入SCSS文件中?Ext.getBody().getSize()可以获取屏幕的高度和宽度,但我认为您不能在SASS中写入Compass,这是获取图像尺寸的函数。将它们与您的精灵地图一起使用将类似于以下内容(警告,未测试): 在最新版本的Sass(3.4)中,sprite-path()返回完整的文件系统路径,而image-width()需要一个相对

我正在构建一个Sencha Touch移动应用程序,并使用该功能创建带有指南针的图像精灵地图

有没有办法计算图像贴图的大小(宽度和高度)并将其作为变量放入SCSS文件中?

Ext.getBody().getSize()可以获取屏幕的高度和宽度,但我认为您不能在SASS中写入Compass,这是获取图像尺寸的函数。将它们与您的精灵地图一起使用将类似于以下内容(警告,未测试):


在最新版本的Sass(3.4)中,sprite-path()返回完整的文件系统路径,而image-width()需要一个相对于images目录的路径。但有一个简单的解决方案:

sprite-width($sprite-map);
sprite-height($sprite-map);

您可以使用神奇的尺寸函数
-sprite height
-sprite width
获得单位值

// Note: "my-icons" represents the folder name that contains your sprites.

@import "my-icons/*.png";
$box-padding: 5px;
$height: my-icons-sprite-height(some_icon);
$width: my-icons-sprite-width(some_icon);

.somediv {
  height:$height + $box-padding;
  width:$width + $box-padding;
}

查看以了解更多详细信息。

这在最新版本的Sass(3.4)中似乎不再有效。sprite path返回完整的文件系统路径,而image width需要一个相对于images目录的路径。不知道他们为什么要改变它。
// Note: "my-icons" represents the folder name that contains your sprites.

@import "my-icons/*.png";
$box-padding: 5px;
$height: my-icons-sprite-height(some_icon);
$width: my-icons-sprite-width(some_icon);

.somediv {
  height:$height + $box-padding;
  width:$width + $box-padding;
}