【问题标题】:SVG translate transform in javascript not working in IE 11javascript中的SVG翻译转换在IE 11中不起作用
【发布时间】:2016-05-09 06:47:50
【问题描述】:

以下代码在 IE 11 中不起作用(Chrome 可以正常工作)

<html>
    <head>
        <script>
            window.onload = function() {document.getElementById("abc").style.transform = "translate(100px,100px)";};
    </script>
</head>
<body>
    <div>   
        <svg width="200" height="200">
            <g id="abc">
                <polygon points="14,7 0,14 0,0"></polygon>
            </g>
        </svg>
    </div>
</body>

【问题讨论】:

标签: javascript html svg transform


【解决方案1】:

对于 IE,您需要将 transform 设置为属性而不是 CSS 样式。

请注意,对于一个属性,单位是不允许的。

<html>
    <head>
        <script>
            window.onload = function() {document.getElementById("abc").setAttribute("transform", "translate(100, 100)")};
    </script>
</head>
<body>
    <div>   
        <svg width="200" height="200">
            <g id="abc">
                <polygon points="14,7 0,14 0,0"></polygon>
            </g>
        </svg>
    </div>
</body>

【讨论】:

    猜你喜欢
    • 2020-06-18
    • 2014-07-19
    • 2014-10-07
    • 2019-12-25
    • 1970-01-01
    • 2020-04-13
    • 2018-09-20
    • 2012-05-08
    • 2014-05-27
    相关资源
    最近更新 更多