父对象高度(绝对定位)

2016-12-19  本文已影响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>
上一篇 下一篇

猜你喜欢

热点阅读