css – Sass/Compass – 将十六进制,RGB或命名的颜色转换为RGBA

前端之家收集整理的这篇文章主要介绍了css – Sass/Compass – 将十六进制,RGB或命名的颜色转换为RGBA前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这可能是指南针101,但有谁写了一个mixin设置一个颜色的alpha值?理想情况下,我希望mixin采取任何形式的颜色定义,并应用透明度:
@include set-alpha( red,0.5 );          //prints rgba(255,0.5);
@include set-alpha( #ff0000,0.5 );      //prints rgba(255,0.5);
@include set-alpha( rgb(255,0),0.5 ); //prints rgba(255,0.5);

解决方法

使用 rgba function built into Sass

Sets the opacity of a color.

Examples:

rgba(#102030,0.5) => rgba(16,32,48,0.5)
rgba(blue,0.2) => rgba(0,255,0.2)

Parameters:
(Color) color
(Number) alpha — A number between 0 and 1

Returns:
(Color)

码:

rgba(#ff0000,0.5); // Output is rgba(255,0.5);
原文链接:https://www.f2er.com/css/223325.html

猜你在找的CSS相关文章