css透明度的设置 (兼容所有浏览器)

本文深入解析了CSS中透明度(opacity)、过滤器(filter)、溢出(overflow)和层级(z-index)属性在网页布局中的应用,特别关注它们在不同浏览器中的兼容性问题。通过实例展示如何使用这些属性实现复杂而美观的视觉效果。
.transparent_class {
      	filter:alpha(opacity=50);
      	-moz-opacity:0.5;
      	-khtml-opacity: 0.5;
      	opacity: 0.5;
     	overflow:hidden;
	background-color: #CAE1FF; 
	width: 100%; 
	height: 100%; 
	position: absolute; 
	left: 0; 
	top: 0; 
	display: none; 
	overflow: hidden;
     	z-index:100;
}


Here is what each of those CSS properties is for:

opacity: 0.5; This is the “most important” one because it is the current standard in CSS. This will work in most versions of Firefox, Safari, and Opera. This would be all you need if all browsers supported current standards. Which, of course, they don’t.
filter:alpha(opacity=50); This one you need for IE.
-moz-opacity:0.5; You need this one to support way old school versions of the Mozilla browsers like Netscape Navigator.
-khtml-opacity: 0.5; This is for way old versions of Safari (1.x) when the rendering engine it was using was still referred to as KTHML, as opposed to the current WebKit .
overflow: (1)visible:默认值。内容不会被修剪,会呈现在元素框之外。 (2):hidden:内容会被修剪,并且其余内容是不可见的。(3):scroll:内容会被修剪,但是浏览器会显示滚动条以便查看其余的内容。(4):auto:如果内容被修剪,则浏览器会显示滚动条以便查看其余的内容。(5):inherit:规定应该从父元素继承 overflow 属性的值
z-index:对于这个属性,我个人的理解是指网页的整体的一个层,和我们视线垂直的网页面,z-index的值越大,这个div离我们的实现就越近,也就是说在别的div的上面。

感谢原文出处:http://justcoding.iteye.com/blog/545301#comments;

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值