0,因为饱和度和亮度不起作用,但在hsl/hsla中却为0%? [英] 0 as saturation and lightness doesn't work but 0% does in hsl/hsla?

查看:59
本文介绍了0,因为饱和度和亮度不起作用,但在hsl/hsla中却为0%?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试一个简单的演示,其中为 hsl 中的元素赋予颜色.根据我的经验,我知道CSS中的 0 (ZERO)是无单位的.如果要将值指定为0,则可以保留单位.

I was trying a simple demo where I gave colors to elements in hsl. From all my experience I know that 0(ZERO) in CSS is unitless. If you want to specify 0 as a value, you may leave the unit.

但是 hsl/hsla 似乎并非如此.在Chrome和Firefox上,这都会导致无效的属性值.

This however doesn't seem to be the case with hsl/hsla. On both Chrome and Firefox, it results in invalid property value.

这是一个与切线相关的问题,但包含的答案是,零应是无规范的.

A tangentially related question was this but that contains the answer that zero should be unitless referring to spec.

是否有hsla(0,0%,0%,0)变为hsla(0,0,0,0)的错误?(缺少百分号)

hsl(0,0,0)     // error
hsl(0,0%,0)    // error
hsl(0,0,0%)    // error

它是专门设计用于零附近的单位吗?像这样的其他属性是否必须在零附近有一个单位?

Is it specifically designed to work with units beside zero? Are there any other properties like this where having a unit beside zero is a must?

推荐答案

CSS中的0< length>是无单位的,不能是0,否则将不能消除歧义(例如简写).这是< percentage>,而不是< length>.

A 0 <length> in CSS is unitless, not any 0, otherwise disambiguation would not be possible (e.g. in shorthands). This is a <percentage>, not a <length>.

规格:

这篇关于0,因为饱和度和亮度不起作用,但在hsl/hsla中却为0%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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