html5页面span元素css:left属性不起作用

时间:2016-03-08 18:11:55

标签: css html5

我正在尝试为span元素设置left和top css属性。这在HTML4页面中工作正常但在HTML5页面上有问题。该代码已发布在jsfiddle https://jsfiddle.net/arunn/pxxgtnqf/上,该代码显示了HTML5页面中的行为。我在这里发布HTML4行为的代码。

<!DOCTYPE>
<html>
    <body>
        <span id='hello' style='position:absolute;top:100px;'>hello</span>
    </body>

    <script type="text/javascript">
        document.getElementById("hello").style.left = 100;
        document.getElementById("hello").style.top = 100;
    </script>
</html>

1 个答案:

答案 0 :(得分:0)

将左侧和上方的值设为包含测量类型的字符串,例如&#34; px&#34;。

toobig: .word 440

Your fiddle updated

相关问题