ie678兼容css3

来源:互联网 发布:arc map空间数据编辑 编辑:程序博客网 时间:2024/06/04 13:00

让IE支持CSS3的圆角、阴影等功能

发布时间: 2012-12-17浏览次数:1570分类: web前端

我的上篇文章css实现IE的阴影效果不尽人意,细心你会发现,IE滤镜的效果不是很好,其实国外的工程师们已经开发了很多让IE支持CSS3的工具,比如说:

1. Dean Edwards的IE7.js (以及 IE8.js, IE9.js)

2. Aaron Gustafson的 eCSStender

3. Drew Diller的 DD_roundies

4. Remiz Rahnas的border-radius.htc

5. Nick Fetchak的 ie-css3.htc

6. Keith Clark的ie-css3.js

7. zoltandulac的cssSandpaper

8.使用CSS3 PIE,官方介绍:http://css3pie.com/
我特地测试了两个,效果还是可以的,案例如下:

一、使用ie-css3.htc实现让IE支持CSS3的圆角、阴影等功能


  1. <html>
  2. <head><title>php点点通-www.phpddt.com 提供教程</title>
  3. <style type="text/css">
  4. .test {
  5. width:200px;
  6. height:200px;
  7. background-color:red;
  8. box-shadow:0px 0px 10px #CCCCCC;/* Opera 10.5+, IE6+ using IE-CSS3 */
  9. -moz-box-shadow:0px 0px 10px #CCCCCC;/* Firefox */
  10. -webkit-box-shadow:0px 0px 10px #CCCCCC;/* Safari and Chrome */
  11. position:relative;
  12. z-index:2;
  13. behavior: url(ie-css3.htc);
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <div class="test">
  19. php点点通-www.phpddt.com 提供教程
  20. </div>
  21. </body>
  22. </html>

•当你使用了这个htc文件后,你的CSS里面,只要写有box-shadow, -moz-box-shadow或-webkit-box-shadow的任何一种,IE就会渲染。

•当使用了这个htc文件后,你不能这样写box-shadow: 0 0 10px red; 而应该是box-shadow: 0px 0px 10px red; 否则IE中会失效。
•behavior: url(ie-css3.htc);的路径问题,要使用绝对路径。

•加上定位属性position:relative

•加上z-index属性z-index:2; 要比周围大,在IE浏览器下这些CSS 3效果的实现是要借助于VML,由VML绘制圆角或是投影效果,所以要设置

demo下载: iecss3.rar

二.使用PIE.htc实现CSS3的圆角阴影和渐变效果


  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>css圆角阴影-来自www.phpddt.com</title>
  6. <style>
  7. #nav {
  8. height:82px;
  9. width:200px;
  10. -moz-border-radius:4px;
  11. -webkit-border-radius:4px;
  12. border-radius:4px;
  13. background:#FC3;
  14. -moz-box-shadow:0px 4px 5px #9C9C9C;
  15. -webkit-box-shadow:0px 4px 5px #9C9C9C;
  16. box-shadow:0px 4px 5px #9C9C9C;
  17. position:relative;
  18. z-index:2;
  19. behavior: url(pie.htc);
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <div id="nav">在本地测试不出效果,需上传到服务器-www.phpddt.com</div>
  25. </body>
  26. </html>

•需要注意的还是上面所说的z-index、绝对路径、缩写形式等问题

demo下载:pie-htc.rar

效果图如下:

让IE支持CSS3的圆角、阴影等功能

0 0
原创粉丝点击