背景颜色的不透明度,但不是文本 [英] Opacity of background-color, but not the text

查看:162
本文介绍了背景颜色的不透明度,但不是文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在文本保持不透明的情况下使 div 的背景透明化跨浏览器(包括Internet Explorer 6)?

How do I make the cross-browser (including Internet Explorer 6) transparency for the background of a div while the text remains opaque?

我需要这样做,而不使用任何库,如jQuery等(但如果你知道一个库,它会的,我很想知道,所以我可以看看他们的代码)。

I need to do it without using any library such as jQuery, etc. (But if you know of a library that does it I'd love to know so I can look at their code).

推荐答案

使用rgba!

.alpha60 {
    /* Fallback for web browsers that don't support RGBa */
    background-color: rgb(0, 0, 0);
    /* RGBa with 0.6 opacity */
    background-color: rgba(0, 0, 0, 0.6);
    /* For IE 5.5 - 7*/
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
    /* For IE 8*/
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";
}




background:transparent 用于IE浏览器,最好通过条件注释或类似方式提供。

In addition to this, you have to declare background: transparent for IE web browsers, preferably served via conditional comments or similar!

通过 http:// robertnyman.com/2010/01/11/css-background-transparency-without-affecting-child-elements-through-rgba-and-filters/

这篇关于背景颜色的不透明度,但不是文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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