Skip to content

background-color: rgba(0,0,0,.5);该属性值最后一个参数,无法设置文字透明! #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dingguangbo opened this issue Oct 30, 2020 · 3 comments

Comments

@dingguangbo
Copy link

dingguangbo commented Oct 30, 2020

https://github.com/mdn/css-examples/blob/master/learn/solutions.md#backgrounds-and-borders该文档中要求,使用rgba颜色为半透明的标题添加了背景颜色, background-color: rgba(0,0,0,.5);这个属性值中最后一个参数无法让文字透明(无法让标题透明)。如果让文字在背景中透明,正确的方法应该使用opacity: 0.5;这个属性!

最初学习文档是https://developer.mozilla.org/zh-CN/docs/Learn/CSS/Building_blocks/Backgrounds_and_borders玩转背景和边框中,第3个要求:给h2标题一个半透明的黑色背景颜色,并使文本为白色。但是解决方案中用了background-color: rgba(0,0,0,.5);所以这个不对的。

@yarusome
Copy link
Contributor

Either the current en-US version of the test says:

  1. Give the <h2> a semi-transparent black background color, and make the text white.

or the current zh-CN version says:

  1. 给<h2>一个半透明的黑色背景颜色,并使文本为白色。

Both clearly suggest that it's the background instead of the text that needs to be semi-transparent, so this issue is out of misunderstanding.

@estelle or @teoli2003, could you close this issue? Thanks in advance!

@yin1999
Copy link
Member

yin1999 commented Apr 24, 2023

Both clearly suggest that it's the background instead of the text that needs to be semi-transparent, so this issue is out of misunderstanding.

👍, I think we could close this :)

@estelle
Copy link
Member

estelle commented May 12, 2023

Yes. This is correct. The background, not the text, should be semi-opaque.

@estelle estelle closed this as completed May 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants