CSS 3 Opacity for List but not text [duplicate]

折月煮酒 提交于 2019-12-24 07:12:27

问题


Possible Duplicate:
Opacity of background, but not the text

I have a HTML unordered list. I need the background to have an opacity of "0.3". But I don't want this opacity applied to the text. Here is my current CSS; it renders the text as having an opacity of 0.3 as well:

li {
    background-color:pink;
    opacity: 0.3;
}

a {
    color: white;
    opacity: 1.0;
}

How do make the link text render white?


回答1:


You'll have to use another way to set your color like rgba like this:

li { background-color: rgba(0,0,0,.3); }

You also need to get rid of the opacity property/value. BTW, the rgb values for the css pink color are: 250,192,203, so: rgba(250,192,203,.3);




回答2:


This is what you need my friend!

http://www.css3.info/introduction-opacity-rgba/

You can't use opacity like that...it gets inherited and has been very annoying to developers for years gone by.



来源:https://stackoverflow.com/questions/11635837/css-3-opacity-for-list-but-not-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!