internet-explorer - 为什么这个 SVG 图形在 IE9 和 10(预览版)中不缩放?

标签 internet-explorer html svg cross-browser

根据 IE website支持 SVG。也根据这个答案What are SVG (Scalable Vector Graphics) supported browsers?

http://jsfiddle.net/jitendravyas/2UWNe/show/

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="100%" height="100%" viewBox="0 0 480 360"
  xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">

  <defs>
    <linearGradient id="button_surface" gradientUnits="objectBoundingBox"
      x1="1" x2="1" y1="0" y2="1">
      <stop stop-color="#434343" offset="0"/>
      <stop stop-color="#000000" offset="0.67"/>
    </linearGradient>

    <linearGradient id="virtual_light" gradientUnits="objectBoundingBox"
      x1="0" x2="0" y1="0" y2="1">
      <stop stop-color="#EEEEEE" offset="0" stop-opacity="1"/>
      <stop stop-color="#EEEEEE" offset="0.4" stop-opacity="0"/>
    </linearGradient>
  </defs>

  <!-- button content -->
  <rect x="10" y="10" rx="15" ry="15" width="150" height="80"
    fill="url(#button_surface)" stroke="#363636"/>

  <text x="30" y="55" fill="white"
    font-family="Tahoma" font-size="20" font-weight="500">
    SVG Button
  </text>

  <!-- vitual lighting effect -->
  <rect x="12" y="12" rx="15" ry="15" width="146" height="76"
    fill="url(#virtual_light)" stroke="#FFFFFF" stroke-opacity="0.4"/>
</svg>

最佳答案

IE 似乎对丢失的 preserveAspectRatio 处理不当属性。您可以通过添加 preserveAspectRatio="xMinYMin slice" 使其在 IE 中缩放,如下所示: http://jsfiddle.net/2UWNe/4/show

但是,IE 显示的不是正确的行为,因此此更改导致其他浏览器的行为与 IE 不同。 (但是,Microsoft believes that they support preserveAspectRatio。)

我没有深入研究您的单位或内容边界框。您真正想要达到什么效果?

关于internet-explorer - 为什么这个 SVG 图形在 IE9 和 10(预览版)中不缩放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7711641/

相关文章:

css - 如何为 SVG 文本设置动画但不是线性的?

javascript - xeponline.jqPlugin.js(或 css2pdf)SVG <use> 引用另一个 SVG 不会在 PDF 中显示

css - 用于在 IE 浏览器窗口顶部放置像素网格的附加组件

javascript - 在 IE 中淡入/淡出文本

javascript - 在该 onload 中使用 onload 定位元素的任何简单方法?

javascript - 显示随机选择的元素

java - Eclipse RAP 应用程序中的浏览器检测

javascript - IE9 中的 Angular JS 页面加载问题

html - 当 URL 包含片段时,iframe 会导致父元素在 Google Chrome 上向上滚动

javascript - 如何使用 SVG map 形状创建可点击链接