【发布时间】:2012-01-26 08:49:08
【问题描述】:
我希望在我的 CSS 文件中拥有一个包含所有图像的根路径的变量。我不太清楚这在纯 Sass 中是否可行(实际的 Web 项目不是 RoR,所以不能使用 assets_pipeline 或任何花哨的爵士乐)。
这是我的例子,它不起作用。在编译时,它会在后台 url 属性中的第一个变量实例说 ("Invalid CSS after "..site/background": expected ")") 时犹豫不决。
定义函数返回路径:
//Vars
$assetPath : "/assets/images";
//Functions
@function get-path-to-assets($assetPath){
@return $assetPath;
}
使用函数:
body {
margin: 0 auto;
background: url($get-path-to-assets/site/background.jpg) repeat-x fixed 0 0;
width: 100%; }
任何帮助将不胜感激。
【问题讨论】: