美文网首页
父对象高度(绝对定位)

父对象高度(绝对定位)

作者: 智多牛 | 来源:发表于2016-12-19 10:08 被阅读0次

<style>

    #box
    {
        width: 100px;
        height: 100px;
        position: absolute;
    }
    
    #rect
    {
        width: 500px;
        height: 500px;
        position: absolute;
    }
    
</style>

<div id="box">
    
    <div id="rect"></div>
    
</div>

<script>
        var node = document.getElementById('box')
    console.log(window.getComputedStyle(node,null)['height'])  //输出:100px
    console.log(node.scrollHeight) //输出:500
</script>

相关文章

网友评论

      本文标题:父对象高度(绝对定位)

      本文链接:https://www.haomeiwen.com/subject/gcttvttx.html