css样式透明在ie6兼容怎么改?

html-css011

css样式透明在ie6兼容怎么改?,第1张

ie6下的完全透明,直接使用transparent就能全部兼容

.bg{background:transparent}

2、只有半透明才需要用到filter滤镜来处理.

.bg{

background: #000000

filter:Alpha(opacity=50)/* 只支持IE6、7、8、9 */

position:static/* IE6、7、8只能设置position:static(默认属性) ,否则会导致子元素继承Alpha值 */

*zoom:1/* 激活IE6、7的haslayout属性,让它读懂Alpha */

}

目标背景样式只能用这种方法去做

background:url("images/search_inpbg.png")

no-repeat

0

0*background:

none

transparent

scroll

repeat

0%

0%

FILTER:

progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/search_inpbg.png',

sizingMethod='scale')

滤镜里面的图片是相对于你页面的路径。而不是样式的路径

。。。。你可以去看下我的

http://www.ok22.org

指向视频

会显示播放效果..你可以把我的样式下载下来看下。加粗是你应该理解的地方。其实滤镜的图片要刚刚跟你控制的DIV大小一样才行。。(除非你用的是一个的没有过渡效果透明PNG)这样才不会变形

这个需要用到JS 首先,打开Dreamweaver,新建一个JavaScript基本页,并复制以下代码替换掉里面的代码,完成后保存为png.js文件// Correctly handle PNG transparency in Win IE 5.5 or higher.

function correctPNG()

{

for(var i=0i<document.images.lengthi++)

{

var img = document.images[i]

var imgName = img.src.toUpperCase()

if (imgName.substring(imgName.length-3, imgName.length) == "PNG")

{

var imgID = (img.id) ? "id='" + img.id + "' " : ""

var imgClass = (img.className) ? "class='" + img.className + "' " : ""

var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "

var imgStyle = "display:inline-block" + img.style.cssText

if (img.align == "left") imgStyle = "float:left" + imgStyle

if (img.align == "right") imgStyle = "float:right" + imgStyle

if (img.parentElement.href) imgStyle = "cursor:hand" + imgStyle

var strNewHTML = "<span " + imgID + imgClass + imgTitle

+ " style=\"" + "width:" + img.width + "pxheight:" + img.height + "px" + imgStyle + ""

+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"

+ "(src=\'" + img.src + "\', sizingMethod='scale')\"></span>"

img.outerHTML = strNewHTML

i = i-1

}

}

}

window.attachEvent("onload", correctPNG)然后打开你要使PNG透明的页面,在<head>区内插入下面代码,注意一下地址就可以了<script type="text/javascript" src="png.js"></script>