html - SVG 在 Internet Explorer 中的大小不正确

标签 html css internet-explorer svg

我知道 IE 中的 SVG 支持很不稳定,但人们已经设法让它从 IE9 开始正常工作。

我正在创建电影院座位选择类型的东西 - 很像预订电影时在此处找到的 AMC:https://www.amctheatres.com/movies/focus#31347

但是在 IE 中,我的 svg 渲染得非常小。我一辈子都弄不明白。

这是我打开的 svg 代码及其内部的几个位:

<svg preserveAspectRatio="xMidYMin" height="100%" width="100%" viewBox="0, 0, 440, 380">

    <rect width="440" height="7" style="fill:#333e48;"> <!-- The screen --> 

    <g transform="translate(360, 300)">
        <circle cx="10" cy="10" r="8" class="disabled circle" fill="#c6cacd" data-rowindex="3" data-columnindex="3" data-seatnumber="P18" data-areacategorycode="0000000004" data-areanumber="1"></circle>
    </g>
    ...

最佳答案

所以我终于弄明白了。使用评论中提到的@paulie_D 的文章。

这是跨浏览器工作的 JSfiddle:http://jsfiddle.net/91b0L2tg/1/

这是原文:https://css-tricks.com/scale-svg/

.svg-container {
   position: relative; 
   height: 0; 
   width: 100%; 
   padding: 0;
   padding-bottom: 100%; 
}

svg {
    position: absolute; 
    height: 100%; 
    width: 100%; 
    left: 0; 
    top: 0;
}

一点点工作,就可以使用了。

它不工作的原因是因为 IE 要求容器 div 将宽度设置为固定宽度而不是 100%

关于html - SVG 在 Internet Explorer 中的大小不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28835822/

相关文章:

javascript - 使用 HTML 时如何允许国家标签自动隐藏?

css - 带有 CSS float div 的多行

css - 使用 CSS 为 IE 样式化提交按钮

css - 如何覆盖 CSS 或为 node_module 重新换肤?

css - 文本动画在 IE 中不起作用

javascript - 某些 Google map 标记未显示在 Internet Explorer 中,但显示在所有其他浏览器中

html - 桌面屏幕的 Bootstrap 导航栏中缺少链接

javascript - 原生 Android 浏览器上的链接问题

javascript - 使用 Javascript/jQuery 将重定向上的 POST 数据发送到顶级 iframe?

javascript - 如何改变一个div的几个子div的样式?