原文网址:http://blog.csdn.net/cuixiping/article/details/4227283 

以下代码在IE运行正常

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
< html xmlns:v="urn:schemas-microsoft-com:vml">
< head><title>VML</title>
< style> v/:* { behavior: url(#default#VML); } </style>
< /head>
< body>
< v:rect id=myrect filled="false" stroked="false" rotation="45"
style="position:relative;width:165px;height:55px;border:none;rotation:45;">
<v:imagedata src="http://www.csdn.net/Images/logo_csdn.gif"/>
< /v:rect>
< /body>
< /html>

如果将DOCTYPE换成XHTML的(如下)则不能运行:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
< head><title>VML</title>
< style> v/:* { behavior: url(#default#VML); } </style>
< /head>
< body>
< v:rect id=myrect filled="false" stroked="false" rotation="45"
style="position:relative;width:165px;height:55px;border:none;rotation:45;">
<v:imagedata src="http://www.csdn.net/Images/logo_csdn.gif"/>
< /v:rect>
< /body>
< /html>

经多方查证,得知故障原因为XHTML环境下v/:*在样式表语法中是非法的,因而被IE8忽略而导致无法渲染VML(说明:IE7下的XHTML仍然能够识别v/:*),而如下代码则可以正确渲染VML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
< head><title>VML</title>
< ?import namespace="v" implementation="#default#VML" ?>
< style> v/:rect,v/:rect,v/:imagedata { display:inline-block } </style>
< /head>
< body>
< v:rect id=myrect filled="false" stroked="false" rotation="45"
style="position:relative;width:165px;height:55px;border:none;rotation:45;">
<v:imagedata src="http://www.csdn.net/Images/logo_csdn.gif"/>
< /v:rect>
< /body>
< /html>

秘诀就是:

<?import namespace="v" implementation="#default#VML" ?>
< style> v/:rect,v/:rect,v/:imagedata { display:inline-block } </style>

(1)通过import来引入命名空间

(2)将所有用到的vml元素分开写入样式{ display:inline-block }

参考网址:

https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=333905

最新文章

  1. leetcode bugfree note
  2. Java面试宝典答案详解与感悟(第二天)
  3. 53. Android常用工具类
  4. stream_copy_to_stream的使用
  5. arcgis 栅格计算器(Spatial Analyst/Raster Calculator)
  6. ASP.NET验证控件一
  7. sql, plsql 总结
  8. 无责任Windows Azure SDK .NET开发入门篇一[Windows Azure开发前准备工作]
  9. Python print语句
  10. 【Noip2017游记】
  11. ●BZOJ 4310 跳蚤
  12. Python WMI获取Windows系统信息
  13. bottle模板中的替换
  14. 移动端常用UI框架
  15. 【392】Python 列表解析
  16. ext与xfs文件系统比较与总结
  17. h5游戏引擎有哪些
  18. 【java】类的初识
  19. 学习QT——GUI的基础用法(2)
  20. bzoj千题计划265:bzoj4873: [六省联考2017]寿司餐厅

热门文章

  1. 通过BroadCast与service时时监听网络变化
  2. appserver安装常见的问题
  3. You need to use a Theme.AppCompat theme (or descendant) with this activity
  4. codeforces B.Fixed Points
  5. linux创建动态库
  6. 关于vue.js中列表渲染练习
  7. Quartus II 与 Modelsim 联调【转】
  8. PHP 类中的魔术方法
  9. glusterfs 中的字典查询
  10. Torch 7 load saved model failed, 加载保存的模型失败