惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
P
Privacy International News Feed
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
C
CXSECURITY Database RSS Feed - CXSecurity.com
Know Your Adversary
Know Your Adversary
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Attack and Defense Labs
Attack and Defense Labs
NISL@THU
NISL@THU
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
GbyAI
GbyAI
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Y
Y Combinator Blog
C
CERT Recently Published Vulnerability Notes
N
Netflix TechBlog - Medium
S
Security Affairs
Spread Privacy
Spread Privacy
罗磊的独立博客
腾讯CDC
MyScale Blog
MyScale Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
L
LINUX DO - 热门话题
The Cloudflare Blog
L
LangChain Blog
博客园_首页
H
Hacker News: Front Page
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
博客园 - 聂微东
SecWiki News
SecWiki News
A
Arctic Wolf
爱范儿
爱范儿
Google Online Security Blog
Google Online Security Blog
T
Threat Research - Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
有赞技术团队
有赞技术团队
The GitHub Blog
The GitHub Blog
Cyberwarzone
Cyberwarzone
博客园 - 叶小钗
V
Visual Studio Blog
V
V2EX
T
Tailwind CSS Blog
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
D
Docker

博客园 - Apolloge

Ext中的get、getDom、getCmp、getBody、getDoc的区别【转】 Extjs 模板的自定义格式化[转] IT项目开发的75条管理守则【转】 当 eval 返回的 json 值时,提示 Error: Invalid Label 的原因 说说C#下的动态可配置的扩展 介绍一个学习方面的网站 Internet Explorer的hasLayout属性 比较常用集合类如何选择 NET常用Request获取信息 UX、UI、UCD、Usability、IA等设计中的常见名词 中国古代四大神兽图释 软件版本号 中华流传十大吉祥图解 WEB2.0概念诠释 Javascript在页面加载时的执行顺序 URL格式规范 C#.NET 中的类型转换 为什么要进行Code Review? Transact SQL小手册
IE, FireFox, Opera 浏览器支持CSS实现Alpha半透明的方法
Apolloge · 2008-11-03 · via 博客园 - Apolloge

1、对于IE使用filter,对于非IE浏览器使用png背景图填充

先请看如下代码:

filter:alpha(opacity=50);       /* IE */
-moz-opacity:0.5;              
/* Moz + FF */
opacity: 0.5;           
/* 支持CSS3的浏览器(FF 1.5也支持)*/

简单解释,IE使用私有属性filter:alpha(opacity),Moz Family使用私有属性-moz-opacity,而标准的属性是opacity(CSS 3, Moz Family部分支持CSS3)。后面的数值是透明度,使用百分比或者小数(alpha(opacity))使用大于0小于100的数值,其实也是百分比,但是需要注意的是,IE下使其私有属性生效必须触发其hasLayout,比如设置容器宽度,最通用的方案是{zoom:1}。)。

从上面的代码中你没有看到Opera。没错,从Opera9开始支持CSS3的opacity了,也没有其私有的可支持Alpha透明的属性。

但是,我们知道,Opera是支持Alpha透明的PNG图片的(当然Moz Family也支持)。所以我们可以使用背景图片来实现Alpha透明效果。

例子:http://www.omemo.net/neo/lab/alpha/

关键在于:

background: transparent url(alpha80.png) left top repeat!important;
background: #ccc;
filter:alpha(opacity=50);

既然Moz Family支持Alpha透明的PNG,所以我们没有必要使用其私有属性了。当然,你可以使用标准的opacity,但别同时使用Alpha透明图片和opacity,这样的话就成了两者的混合了。你可以把上面的例子下载过来,然后/*opacity: .5;*/的注释看看。

这部分内容来自于:http://www.omemo.net/neo/blog/?p=87

2、如想实现父标签透明,而子标签不透明,采用对于采用png透明的父标签来说不存在问题,如果采用alpha值无论ie还是非ie都存在这样的问题,css声明了position透明标签包含的内容都透明。

例如:

<div id="out"><div id="in">不透明<div><div>
   out
{

     position
: absolute;
     top
:0;
     left
: 0;
     width
: 100%;
     background
:url(../img/alpha30.png);/*非ie*/
     filter
:alpha(opacity=30);/*ie*/
}
   in
{
     background
:#fff
}

这个时候看到in也是透明的

hack方法:增加一个子标签,采用css hack 使其在ie下充满整个父标签,并使其透明,由于透明部分和不透明部分是兄弟关系,所以不影响。

<div id="out"><div id="in">不透明<div><div id="ie">不透明<div><div>
 out
{

     position
: absolute;
     top
:0;
     left
: 0;
     width
: 100%;
     background
:url(../img/alpha30.png);
     z-index
: 100;
}
   in
{
     background
:#fff
}

*html out

{
background
:out;
}
*html ie
{
     position
: absolute;
     top
:0;
     left
: 0;
     width
: 100%;
     height
:100%;
     background
:url(../img/alpha30.png);
     filter
:alpha(opacity=30);
     z-index
: -1;/*让其位于in的下面*/
}

 该想法来自于http://www.webmasterworld.com/forum83/3529.htm