Get top coordinate of self

This question already has an answer here:

  • Make a div fill the height of the remaining screen space 31 answers

  • Instead of using calc (since your upper element is of unknown height)...
    you can easily achieve this using flexbox

    /*QuickReset*/ *{margin:0;box-sizing:border-box;} html,body{height:100%;font:14px/1.4 sans-serif;}
    
    
    .flex-column {
      height: 100%;
      display: flex;
      flex-direction: column;
    }
    
    .grow{
      flex: 1;
      background: gold;
    }
    <div class="flex-column">
    
      <div>
        I<br>have <br>unknown<br>height
      </div>
    
      <div class="grow">
        occupy space below
      </div>
    
    </div>
    链接地址: http://www.djcxy.com/p/88254.html

    上一篇: HTML5 iFrame无缝属性

    下一篇: 获取自我的顶部坐标