你应该使用rgba(0,0,0,0)或rgba(255,255,255,0)CSS中的透明度吗? [英] Should you use rgba(0, 0, 0, 0) or rgba(255, 255, 255, 0) for transparency in CSS?

查看:385
本文介绍了你应该使用rgba(0,0,0,0)或rgba(255,255,255,0)CSS中的透明度吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应使用 rgba(0,0,0,0) rgba(255,255,255,0)

推荐答案

由于最后一个参数是alpha参数,如果将它设置为0,它将意味着完全透明,前三个参数(红色,绿色,蓝色)

Given that the last parameter is the "alpha" parameter, if you set it to 0 it will mean "completely transparent", and the first three parameters (red, green, blue) won't matter because you won't be able to see the color anyway.

考虑到这一点,我仍然会选择 rgba(0,0,0, 0),因为:

With that in mind, I would still choose rgba(0, 0, 0, 0) because:


  1. 键入较少,


  2. 如果Alpha值更改为不需要的值,您会看到一个明显的问题。

可以完全避免使用 rgba 模型,并使用 transparent 值,根据 w3.org ,是等效的到透明黑色,并应计算为 rgba(0,0,0,0)。例如:

You could avoid the rgba model altogether and use the transparent value instead, which according to w3.org, is equivalent to "transparent black" and should compute to rgba(0, 0, 0, 0). For example:

h1 {
    background-color: transparent;
}

这会节省你另外几个字节,而你使用透明度的意图是显而易见的以防万一不熟悉RGBA)。

This saves you yet another couple bytes while your intentions of using transparency are obvious (in case one is unfamiliar with RGBA).

这篇关于你应该使用rgba(0,0,0,0)或rgba(255,255,255,0)CSS中的透明度吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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