{Sass::Script::Functions color functions}颜色函数

本文深入解析CSS中的颜色函数,包括RGB、HSL及其透明度变化,以及如何调整颜色的色调、饱和度、亮度等属性。通过实例展示了颜色函数在SCSS中的应用,如改变颜色、调整颜色属性和设置透明度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

RGB Functions

rgb($red, $green, $blue)

HSL Functions

hsl($hue, $saturation, $lightness) 

hsl(hue, saturation, lightness)    //色相、饱和度、亮度

hsla($hue, $saturation, $lightness, $alpha)

hsla(hue, saturation, lightness, alpha)   //色相、饱和度、亮度、透明度

hue($color)  //获取颜色的色调

saturation($color)  //获取颜色的饱和度

lightness($color)   //获取颜色的亮度

adjust-hue($color, $degrees)   //  增加或减少$color色调。

lighten($color, $amount)      //Makes a color lighter.

darken($color, $amount)    //Makes a color darker.

saturate($color, $amount)   //Makes a color more saturated.

desaturate($color, $amount)  //Makes a color less saturated.

grayscale($color)       //灰度

complement($color)    //互补

invert($color)    //反相

Opacity Functions

alpha($color) / opacity($color)   //获取一个颜色的透明度

rgba($color, $alpha)   //Add or change an alpha layer for any color value.

opacify($color, $amount) / fade-in($color,$amount)     //Makes a color more opaque.

transparentize($color, $amount) / fade-out($color,$amount)     //Makes a color more transparent.

Other Color Functions

adjust-color($color, [$red], [$green], [$blue], [$hue],[$saturation], [$lightness], [$alpha])   //递增或递减一个颜色任何属性

scale-color($color, [$red], [$green], [$blue], [$saturation],[$lightness], [$alpha])    //基于颜色属性上流动划分百分值

change-color($color, [$red], [$green], [$blue], [$hue],[$saturation], [$lightness], [$alpha])   //设置任何一颜色的属性

ie-hex-str($color)

scss:
color: change-color(#8ec63f, $red: 60, $green: 255)

color: adjust-color(#8ec63f, $hue: 300, $lightness: 50%)

color: scale-color(#8ec63f, $lightness: 25%, $alpha: 30%)

编译后css:
color: #3cff3f;    color: white;   color: #aad46f;

https://sass-lang.com/documentation/functions/color

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值