首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SCSS地图不会在Compass中编译

SCSS地图不会在Compass中编译
EN

Stack Overflow用户
提问于 2014-04-08 16:27:31
回答 2查看 1.2K关注 0票数 1

我编写了一个SCSS映射变量和一个@each循环来为文件下载链接分配不同的图标,如下所示。

代码语言:javascript
复制
$file-icons: (
"application/vnd.ms-excel": "../images/ico-excel.png",
"application/pdf": "../images/ico-pdf.png",
"image/tiff": "../images/ico-img.png",
"image/gif": "../images/ico-img.png",
"image/png": "../images/ico-img.png",
"image/jpeg": "../images/ico-img.png",
"application/x-shockwave-flash": "../images/ico-flash.png",
"audio/mpeg": "../images/ico-audio.png"
);

@each $file in $file-icons {
  img[title="#{nth($file, 1)}"] + a:hover {
    background: url("#{nth($file, 2)}") right top no-repeat;
  }
}

当我在萨斯迈斯特上测试它时,它的编译与我所期望的完全相同:

代码语言:javascript
复制
img[title="application/vnd.ms-excel"] + a:hover {
  background: url("../images/ico-excel.png") right top no-repeat;
}

img[title="application/pdf"] + a:hover {
  background: url("../images/ico-pdf.png") right top no-repeat;
}

img[title="image/tiff"] + a:hover {
  background: url("../images/ico-img.png") right top no-repeat;
}

img[title="image/gif"] + a:hover {
  background: url("../images/ico-img.png") right top no-repeat;
}

img[title="image/png"] + a:hover {
  background: url("../images/ico-img.png") right top no-repeat;
}

img[title="image/jpeg"] + a:hover {
  background: url("../images/ico-img.png") right top no-repeat;
}

img[title="application/x-shockwave-flash"] + a:hover {
  background: url("../images/ico-flash.png") right top no-repeat;
}

img[title="audio/mpeg"] + a:hover {
  background: url("../images/ico-audio.png") right top no-repeat;
}

我用罗盘来做这个项目。当我使用compass compile时,我会得到以下错误。

代码语言:javascript
复制
user@machine:~/project$ compass compile
    error sass/style.scss (Line 2 of sass/_partial.scss: Invalid CSS after "...n/vnd.ms-excel"": expected ")", was ": "../images/ic...")
   create stylesheets/style.css

我不知道是什么导致了这个错误。它是否与Sass的新地图有关,也许Compass还没有完全支持它呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-04-08 20:33:23

当前稳定版的Compass (版本0.12.2)是在2012年6月发布的,因此它不支持Sass v3.3.0的新地图功能。(Sassmeister目前正在使用Compass的v1.0.alpha 18,这就是Sass在那里编译的原因。)

安装Compass的最新测试版:

代码语言:javascript
复制
gem install compass --pre

即1.0.a.19版(2014年3月)。

票数 2
EN

Stack Overflow用户

发布于 2014-04-08 20:31:30

您使用的是什么版本的Compass/Sass?Sass 3.3中的地图是新的,只有Compass 1.0预发行版才支持它.gem install compass --pre来获取最新消息。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22942885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档