【问题标题】:Setting stylus variables programmatically以编程方式设置触控笔变量
【发布时间】:2015-07-29 12:21:13
【问题描述】:

我正在处理一个项目,其中一个手写笔文件应该根据 Javascript 代码中定义的变量吐出不同的 CSS。我找到了the Javascript API,但无法找到一种干净又好的方式来以编程方式设置变量。

任何人都知道如何使用 Node.js 在 Stylus 中设置颜色变量并返回 CSS?

【问题讨论】:

    标签: stylus


    【解决方案1】:

    类似:

    var stylus = require('stylus');
    
    stylus('body\n  color: some-color')
      .define('some-color', new stylus.nodes.RGBA(128, 128, 128, 1)) // #808080
      .render(function(err, css) {
        if (err) throw err;
        console.log(css);
      });
    

    请参阅 lib/nodes/rgba.jslib/nodes/hsla.js

    我猜你也可以使用json bif 来完成你的任务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-14
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      • 2012-12-14
      • 2012-10-16
      • 2018-08-02
      • 1970-01-01
      相关资源
      最近更新 更多