我编写了一个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;
}
}当我在萨斯迈斯特上测试它时,它的编译与我所期望的完全相同:
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时,我会得到以下错误。
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还没有完全支持它呢?
发布于 2014-04-08 20:33:23
当前稳定版的Compass (版本0.12.2)是在2012年6月发布的,因此它不支持Sass v3.3.0的新地图功能。(Sassmeister目前正在使用Compass的v1.0.alpha 18,这就是Sass在那里编译的原因。)
安装Compass的最新测试版:
gem install compass --pre即1.0.a.19版(2014年3月)。
发布于 2014-04-08 20:31:30
您使用的是什么版本的Compass/Sass?Sass 3.3中的地图是新的,只有Compass 1.0预发行版才支持它.gem install compass --pre来获取最新消息。
https://stackoverflow.com/questions/22942885
复制相似问题