LESS: darken() on current color

梦想与她 提交于 2020-01-02 05:28:09

问题


I want to call LESS's darken() function on whatever the current color is (I don't have the current color in any variable). Is that possible?


回答1:


as per seven-phases-max request; in your node backend let say express

var less = require('less'); //also the body parser, express, etc

....

from your page you make an asynchronous request with the actual color of your page, just grabbing it with js and making the request. then in express:

app.post('/whateveryourroute', function(req, res) {
    var colorFromReq = req.body.color;
    less.render('.class { color: darken(`colorFromReq`, 20%) }', function (e, css) {
      res.header("Content-type", "text/css");
      res.send(css);
    });
});

Something like that would be, didnt test it, but is possible.



来源:https://stackoverflow.com/questions/25451737/less-darken-on-current-color

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!