Linear-gradient() 使用哪个颜色空间?

发布于 2025-01-20 15:55:05 字数 68 浏览 5 评论 0 原文

CSS的线性级函数()函数使用RGB,HSL或HSV哪个颜色空间?为什么?

我可以更改自己选择的颜色空间吗?

Which color space does CSS's linear-gradient() function uses, RGB, HSL or HSV and why ?

Can I change the color space of my own choice ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世界等同你 2025-01-27 15:55:05

将来您可以指定颜色空间

与 [css3-images] 相比,此级别添加了一个标记来自定义渐变中的颜色插值,如 CSS Color 4 § 12 Interpolation 中所述。

linear-gradient() = linear-gradient(
  [ <angle> | to <side-or-corner> ]? || <color-interpolation-method>,
  <color-stop-list>
)
<side-or-corner> = [left | right] || [top | bottom]

如果您想测试,您可以继续阅读以获取更多详细信息


Safari对此有一些支持: https://twitter .com/argyleink/status/1490376117064065025

In the future you can specify the color space

Compared to [css3-images], this level adds a token to customize color interpolation in gradients as described in CSS Color 4 § 12 Interpolation.

linear-gradient() = linear-gradient(
  [ <angle> | to <side-or-corner> ]? || <color-interpolation-method>,
  <color-stop-list>
)
<side-or-corner> = [left | right] || [top | bottom]

You can keep reading for more detail


Safari has some support for this if you want to test: https://twitter.com/argyleink/status/1490376117064065025

不喜欢何必死缠烂打 2025-01-27 15:55:05

如果您未在渐变函数中指定颜色空间,则默认空间为 sRGB(尽管 Chrome 有一个错误,这在 MacOS 中不太正确)。

浏览器已开始发布 较新的语法,允许您指定颜色空间:线性渐变(在 oklch 90deg、红色、蓝色中)。有效的颜色空间为 hslhwblchoklch(极坐标空间)和 srgb< /code>、srgb-线性laboklabxyzxyz-d50代码>,和xyz-d65(矩形空间)。

截至 2023 年末,Chrome、Safari 和 Edge 支持此语法,但 Firefox 不支持。

If you don't specify a color space in the gradient function, the default space is sRGB (though Chrome has a bug where this is not quite right in MacOS).

Browsers have begun to ship the newer syntax, which allows you to specify the color space: linear-gradient(in oklch 90deg, red, blue). Valid color spaces are hsl, hwb, lch, oklch (the polar spaces) and srgb, srgb-linear, lab, oklab, xyz, xyz-d50, and xyz-d65 (the rectangular spaces).

As of late 2023, this syntax is supported in Chrome, Safari, and Edge, but not Firefox.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文