更少:在当前颜色上变暗 [英] LESS: darken() on current color

查看:83
本文介绍了更少:在当前颜色上变暗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论当前颜色是什么,我都想调用LESS的darken()函数(我在任何变量中都没有当前颜色).有可能吗?

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?

推荐答案

按照最大7个阶段的请求;在您的节点后端,说快递

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

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

....

从页面上发出一个具有页面实际颜色的异步请求,只需使用js抓取并发出请求即可.然后在快递中:

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.

这篇关于更少:在当前颜色上变暗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆