How to stretch an HTML table to 100% of the browser window height?

前端 未结 3 1426
攒了一身酷
攒了一身酷 2021-01-04 11:04

I\'m using a table to design the layout of my web page. I want the table to fill the page even if it doesn\'t contain much content. Here\'s the CSS I\'m using:



        
相关标签:
3条回答
  • 2021-01-04 11:15

    Try using this:

    html, body    {
      height: 100%;
    }
    

    So besides making the table's height to 100%, you also should have to make sure that the html'd and body's height are also 100%, so it will stretch properly.

    0 讨论(0)
  • 2021-01-04 11:23

    You can handle this in Javascript/JQuery.

    window_height = $(window).height();
    $('#container').css('min-height', window_height);
    
    0 讨论(0)
  • 2021-01-04 11:35

    Just use the height property instead of the min-height property when setting #container. Once the data gets too big, the table will automatically grow.

    0 讨论(0)
提交回复
热议问题