CSS opacity vs rgba: which one is better?

前端 未结 4 865
盖世英雄少女心
盖世英雄少女心 2020-12-08 02:28

Assuming you\'re applying a CSS opacity to a solid color. Is it better, in terms of memory and performance, to use an rgba value or the color+opacity?

4条回答
  •  执念已碎
    2020-12-08 03:13

    opacity only applies to entire elements, so you cannot apply an alpha channel to a color using the opacity property. You can only do that with the rgba() (or hsla()) function.

    So rgba()/hsla() is better in all aspects because that's the only way to do it.

提交回复
热议问题