使用Filters滤镜弥补CSS3的跨浏览器问题以及兼容低版本IE( 三 )




!Doctype html html head meta charset="UTF-8" / titleie半透明层/title style type="text/css" body{background:#fee;} .Box{ position:relative;width:300px;height:200px;border:1px solid #ccc; } .ieAlpha{ position:absolute;z-index:-1;top:0;left:0;width:300px;height:200px;background:#333; filter:alpha(opacity=30); } /style /head body div class=’Box’ div class=’ieAlpha’/div 透明背景 /div /body /html
ffcod = delpost.runcode29 .value; ffcod = ffcod.replace(/
/g,’’); delpost.runcode29 .value = https://www.rkxy.com.cn/dnjc/ffcod; 提示:您可以先修改部分代码再运行
这种方法使用的比较普遍,但是多加的一层实在有些多余,并且有时候控制起来还比较麻烦 。
我们可以换一个滤镜方法:在上面的渐变的滤镜里,我们提到了渐变色也可以使用alpha半透明值,并且这个渐变滤镜是针对于元素背景的,元素内容并不会受其影响 。
那么我们可以这样实现:


!Doctype html html head meta charset="UTF-8" / title利用gradient实现半透明层/title style type="text/css" body{background:#fee;} .Box{ position:relative;width:300px;height:200px;border:1px solid #ccc; filter:progid:DXImageTransform.Microsoft.gradient(gradientType = 1,startColorstr = #66000000,endColorstr = #66000000); } /style /head body div class=’Box’ 透明背景 /div /body /html
ffcod = delpost.runcode30 .value; ffcod = ffcod.replace(/
/g,’’); delpost.runcode30 .value = https://www.rkxy.com.cn/dnjc/ffcod; 提示:您可以先修改部分代码再运行
显然结构,样式简单多了,再做一下其他浏览器的兼容性:


!Doctype html html head meta charset="UTF-8" / title半透明层/title style type="text/css" body{background:#fee;} .Box{ position:relative;width:300px;height:200px;border:1px solid #ccc; background:rgba(0,0,0,0.35); /* 这里也不独立使用opacity了 */ filter:progid:DXImageTransform.Microsoft.gradient(gradientType = 1,startColorstr = #66000000,endColorstr = #66000000); } /style /head body div class=’Box’ 透明背景 /div /body /html
ffcod = delpost.runcode31 .value; ffcod = ffcod.replace(/
/g,’’); delpost.runcode31 .value = https://www.rkxy.com.cn/dnjc/ffcod; 提示:您可以先修改部分代码再运行
虽然我们以上解决了四种ie低版本下的不足,但在解决的过程中某些地方还是稍显繁复了,且在具体应用当中的情况或许并没有这么简单,读者当理解之后再做延伸 。
除了以上四种问题被解决之外,还是有太多的css3效果在ie低版本下是无法实现的,我们不得不(在低版本浏览器中)放弃之,其中最最最遗憾的就是css3圆角效果了,当然使用VML也是能解决,封装的方法:Curved corner,同DD_belatedPNG一样,我还是建议读者谨慎采用 。
ie各个Filters静态滤镜演示Demo:DXTidemo

推荐阅读