css - COMPASS/SASS 如何将变量插入到@import "sprite/*.png"路径?

标签 css sass compass-sass

我在自己(某种程度上)的 SASS/COMPASS“框架”上工作。

我设置了一个变量 - $sprite - 这是存储所有图像的文件夹的名称。

我这样做是为了稍后我可以使用该名称来替换图像混合和 Sprite 生成。

如果@import "#{$sprite}/*.png"正常工作,一切都会很棒。

有什么想法吗?

    //sprite images folder name
        $sprite: "sprite";

    //settings
        $sprite-sprite-base-class: ".#{$sprite}" - *works*;
        $sprite-spacing: 20px;
        $sprite-sprite-dimensions: true;

    //generate sprite
        @import "sprite/*.png"; - normal path - *works*
        @import "#{$sprite}/*.png" - path with a variable in it - *doesn't work*

    //mixin        
        @mixin replace-with-image($imageName){
            @include replace-text-with-dimensions("#{$sprite}/#{$imageName}.png");
            @extend %dis-ib;
        } - *works*

最佳答案

恐怕目前这根本不可能(而且永远不会像 the issue that steveax posted 中看起来的那样)。如果你真的想要这个,你将不得不编写你自己的小预处理器来解析你的变量,然后将它输出到 .sass/.scss 文件。或者,提交功能请求...

关于css - COMPASS/SASS 如何将变量插入到@import "sprite/*.png"路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14912243/

相关文章:

css - compass 1.0.0 预览文档位于何处?

html - 'after' 的样式在浏览器中有所不同

javascript - 使用位置 :sticky for the bottom of a div Container

javascript - 高度扩展时背景颜色渗入主体

css - 悬停状态下的选项卡可访问性

sproutcore - 有没有办法将 960 和 compass 与 sproutcore 一起使用?

css - SCSS 和 SCOUT 问题

javascript - 将 jQuery 应用于 div 的每个部分

推送到moovcloud时SASS编译错误?

CSS 不适用于映射 Font Awesome 图标