以下代码在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>

最佳答案

对于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>

关于javascript - javascript中的SVG转换转换无法在IE 11中运行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37109349/

10-12 12:29
查看更多