如何转换HEX颜色为rgba与Less编译器? [英] How to convert HEX color to rgba with Less compiler?
本文介绍了如何转换HEX颜色为rgba与Less编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
@color : #d14836;
.stripes span {
-webkit-background-size: 30px 30px;
-moz-background-size: 30px 30px;
background-size: 30px 30px;
background-image: -webkit-gradient(linear, left top, right bottom,
color-stop(.25, rgba(209, 72, 54, 1)), color-stop(.25, transparent),
color-stop(.5, transparent), color-stop(.5, rgba(209, 72, 54, 1)),
color-stop(.75, rgba(209, 72, 54, 1)), color-stop(.75, transparent),
to(transparent));
我需要将 @color
转换为 rgba(209,72,54,1)
。
所以我需要替换 rgba (209,72,54,1)
在我的代码与Less函数生成 rgba()
值从我的 @
So I need to replace rgba(209, 72, 54, 1)
in my code with Less function that generates rgba()
value from my @color
variable.
推荐答案
方案
实际上,LESS语言带有一个嵌入的函数 fade
。您可以这样使用:
Actually, the LESS language comes with an embedded function called fade
. You can use it this way:
fade(@color, 50%); // return @color with 50% transparency in rgba
这篇关于如何转换HEX颜色为rgba与Less编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文