IE6 中DIV透明度用JS如何设置?

JavaScript018

IE6 中DIV透明度用JS如何设置?,第1张

直接可以用CSS设置

示例:

<!DOCTYPE

html

PUBLIC

"-//W3C//DTD

XHTML

1.0

Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html

xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta

http-equiv="Content-Type"

content="text/html

charset=utf-8"

/>

<title>无标题文档</title>

<style>

body{

background:#000}

.AlphaBg

{

background:#fff

filter:alpha(opacity=50)

-moz-opacity:0.50

opacity:0.50

width:470px

height:211px

position:

absolute

z-index:30

}

.Contact{

width:470px

height:211px

position:

absolute

z-index:40

color:#fff}

</style>

</head>

<body>

<div

class="AlphaBg"></div>

<div

class="Contact">宽和高与

AlphaBg一样,z-index比

AlphaBg高,position</div>

</body>

</html>

这个是js的

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>Js淡入淡出——Fade效果 - www.codefans.net </title>

<style>

* { font-size:12px}

html { margin:0pxpadding:0pxoverflow:auto}

body { margin:0pxpadding:15pxbackground-color:buttonface}

#w { position:absolutewidth:480pxheight:270pxoverflow:hiddenborder:2px groove #281cursor:default-moz-user-select:nonefilter:alpha(opacity=100)}

#t { line-height:20pxheight:20pxwidth:480pxoverflow:hiddenbackground-color:#27Ccolor:whitefont-weight:boldborder-bottom:1px outset bluetext-align:center}

#winBody { height:248pxwidth:480pxoverflow-x:hiddenoverflow-y:autoborder-top:1px inset bluepadding:10pxtext-indent:10pxbackground-color:white}

</style>

</head>

<body>

<div id="w">

<div id="t">演示Windows的淡入淡出窗口</div>

<div id="winBody">源码爱好者</div>

</div>

</body>

<script>

(function(o,i,s){

i=1s=0.01

setInterval(function(){

i+=ss=i<0?0.01:(i>1?-0.01:s)

if(o.filters)o.filters[0].opacity=i*100

else o.style.opacity=i

},1)

})(document.getElementById("w"))

</script>

</html>

是的,jpg和bmp格式是图像全彩格式,不支持透明的,要做成透明的只能保存成gif格式!ps的具体保存方法是 点 文件->保存为web和设备所用的格式,在那个里面选择gif保存,就可以为透明的了!