How to stretch div height to fill parent div - CSS

后端 未结 7 1441
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 10:05

I have a page with divs like below

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 10:57

    Suppose you have

    
      

    With normal CSS, you can do the following. See a working app https://github.com/onmyway133/Lyrics/blob/master/index.html

    #root {
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 100%;
    }
    

    With flexbox, you can

    html, body {
      height: 100%
    }
    body {
      display: flex;
      align-items: stretch;
    }
    
    #root {
      width: 100%
    }
    

提交回复
热议问题