如何将 HTML 表格拉伸到浏览器窗口高度的 100%? [英] How to stretch an HTML table to 100% of the browser window height?

查看:53
本文介绍了如何将 HTML 表格拉伸到浏览器窗口高度的 100%?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用表格来设计我的网页布局.我希望表格填满页面,即使它不包含太多内容.这是我正在使用的 CSS:

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:

html, body {
    height: 100%;
    margin: 0;
    padding: 0; 
}

#container {
    min-height: 100%;
    width: 100%; 
}

我在页面代码中放置了类似的内容:

And I place something like this in the page code:

<table id="container">
<tr>
<td>
...

这适用于 Opera 9,但不适用于 Firefox 2 或 Internet Explorer 7.是否有一种简单的方法可以使此解决方案适用于所有流行的浏览器?

This works for Opera 9, but not for Firefox 2 or Internet Explorer 7. Is there a simple way to make this solution work for all popular browsers?

(将 id="container" 添加到 td 没有帮助.)

(Adding id="container" to td doesn't help.)

推荐答案

设置 #container 时只需使用 height 属性而不是 min-height 属性.一旦数据变得太大,表会自动增长.

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.

这篇关于如何将 HTML 表格拉伸到浏览器窗口高度的 100%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆