【问题标题】:SCSS Map won't compile in Compass [duplicate]SCSS Map 无法在 Compass 中编译 [重复]
【发布时间】:2014-04-09 04:33:23
【问题描述】:

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

$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;
  }
}

当我在 Sassmeister 上测试它时,它的编译结果完全符合我的预期:

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。当我使用compass compile 时,出现以下错误。

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 还没有完全支持?

【问题讨论】:

    标签: sass compass-sass


    【解决方案1】:

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

    安装最新的 Compass 测试版:

    gem install compass --pre
    

    版本 1.0.0.alpha.19(2014 年 3 月)。

    【讨论】:

    • 感谢您确认我的怀疑并提供解决方法!
    • 奇怪的东西。它在另一台机器上为我工作,但不是在这台机器上。我很确定,我总是以同样的方式安装 Compass。感谢您为我指明正确的方向!
    • 更新。看起来 Bundler 正在安装比 gem install 更新的 Compass 版本。
    【解决方案2】:

    您使用的是什么版本的 Compass/Sass?地图是 Sass 3.3 中的新功能,仅受 Compass 1.0 预发行版支持。 gem install compass --pre 获取最新信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-11
      • 1970-01-01
      • 1970-01-01
      • 2012-10-02
      • 2013-11-02
      • 1970-01-01
      相关资源
      最近更新 更多