<alpha-value> - CSS: Cascading Style Sheets 编辑

The <alpha-value> CSS data type represents a value that can be either a <number> or a <percentage>, specifying the alpha channel or transparency of a color.

Syntax

The value of an <alpha-value> is given as either a <number> or a <percentage>.

If given as a number, the useful range is 0 (fully transparent) to 1.0 (fully opaque), with decimal values in between; that is, 0.5 indicates that half of the foreground color is used and half of the background color is used. Values outside the range of 0 to 1 are permitted, but are clamped to like within the range 0 to 1.

If the alpha value is given as a percentage, 0% corresponds to fully transparent while 100% indicates fully opaque.

Interpolation

When animated, values of the <alpha-value> CSS data type are interpolated as real, floating-point numbers. The speed of the interpolation is determined by the timing function associated with the animation.

Examples

Setting text color opacity

Here an alpha value is used to set partially transparent text:

/* <rgba()> */
color: rgba(34, 12, 64, 0.6);
color: rgba(34.0 12 64 / 60%);

Setting shape image threshold

Here an alpha value is used to determine which parts of an image are considered part of a shape:

/* shape-image-threshold */
shape-image-threshold: 70%;
shape-image-threshold: 0.7;

Specifications

SpecificationStatusComment
CSS Color Module Level 4
The definition of '<alpha-value>' in that specification.
Working DraftNo significant change.
CSS Color Module Level 3
The definition of '<alpha-value>' in that specification.
RecommendationIntroduces <alpha-value> along with rgba() and hsla() functional notations.

See also

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:60 次

字数:4125

最后编辑:7 年前

编辑次数:0 次

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