CSS 修改 LESS 变量的 alpha 不透明度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12771102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 20:24:49  来源:igfitidea点击:

Modify alpha opacity of LESS variable

cssvariableslessopacityalpha

提问by ben

Using LESS, I know that I can change the saturation or tint of a color variable. That looks like this:

使用 LESS,我知道我可以更改颜色变量的饱和度或色调。看起来像这样:

background: lighten(@blue, 20%);

I want to change the alpha opacity of my color, though. Preferably like this:

不过,我想更改颜色的 alpha 不透明度。最好是这样的:

background: alpha(@blue, 20%);

Is there a simple way to do this in LESS?

有没有一种简单的方法可以在 LESS 中做到这一点?

回答by ScottS

The site documentationgives the answer:

网站的文件给出了答案:

background: fade(@blue, 20%);

The function name is fadenot alphaaccording to that document.

函数名称fadealpha符合该文件。

回答by Adrian Enriquez

For completeness

为了完整性

fade

褪色

Set the absolute transparency of a color. Can be applied to colors whether they already have an opacity value or not.

设置颜色的绝对透明度。可以应用于颜色,无论它们是否已经具有不透明度值。

background: fade(@blue, 20%);

fadein

淡入

Decrease the transparency (or increase the opacity) of a color, making it more opaque.

降低颜色的透明度(或增加不透明度),使其更加不透明。

background: fadein(@blue, 80%);

fadeout

淡出

Increase the transparency (or decrease the opacity) of a color, making it less opaque. To fade in the other direction use fadein.

增加颜色的透明度(或降低不透明度),使其不透明。要在另一个方向淡入淡出,请使用淡入淡出。

background: fadeout(@blue, 20%);

View Complete Documentation

查看完整文档