获取表格以填充 td 中的 100% 高度 [英] Getting a table to fill 100% height in a td

查看:15
本文介绍了获取表格以填充 td 中的 100% 高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用适当的 HTML 重写站点.我试图更换的网站一团糟.我遇到了一个问题,我无法获得

来填充它所包含的
的高度.我试过了在 <table> 上设置 height: 100%,基于 google 和 stackoverflow 研究应该可以工作,但我一定遗漏了一些愚蠢的东西.在切换到表格之前,我曾尝试用 <divs> 做同样的事情,但我不反对回到 <divs> 如果有人可以建议怎么做.

I'm trying to rewrite a site in proper HTML. The site I'm trying to replace was a complete mess. I've run into a problem where I can't get a <table> to fill the height of the <td> it's contained in. I've tried setting height: 100% on the <table>, which based on google and stackoverflow research should work, but I must be missing something stupid. I had tried to do the same thing with <divs> before switching to tables, but I'm not opposed to going back to <divs> if someone can suggest how to do it.

我正在开发的内容目前在这里:http://96.0.22.228/

The content I'm developing is currently here: http://96.0.22.228/

由于项目时间限制,我不得不使用糟糕的技巧来使页面看起来正确.我没有声明 并且我强迫 IE 使用 IE7-quirks 模式.我很想就如何使用 HTML5 和 CSS 以正确的方式进行此布局提供建议.它不必支持较旧的浏览器,但它必须在最新版本的 Chrome、Firefox 和 IE 中看起来相同.我还想取消菜单的图像,并在 CSS 中为边框和菜单文本设置所有样式.

Due to project time constraints, I've had to use bad hacks to get the pages looking correctly. I'm not declaring a <doctype> and I'm forcing IE to use IE7-quirks mode. I'd love to have recommendations on how to do this layout in a proper manner using HTML5 and CSS. It does not have to support older browsers, but it does have to look the same in the latest versions of Chrome, Firefox and IE. I'd also like to to do away with the images for the menus and style everything in CSS for the border frames and the menu text.

即使我必须按原样完成网站,但如果此问题有好的答案,我也愿意稍后返回并修复它.

Even though I've had to complete the site as is, I'm open to going back and fixing it later if there's a good answer to this problem.

推荐答案

表格单元格中 100% 的高度总是很痛苦.从技术上讲,TD 没有高度(因为这取决于其内容).您要求浏览器做的是让孩子成为其父的 100%,即其子的 100%,即其父的 100%……您可以看到这可能是一个问题.

100% height in a table cell is always a pain. Technically speaking a TD has no height (because that depends on its contents). What you are asking the browser to do is make the child 100% of its parent, which is 100% of its child, which is 100% of its parent ... You can see how that might be a problem.

您可以尝试向 TD 添加明确的高度并使用 table-layout:fixed 在桌子上.至少这样浏览器就可以知道父级的高度而不需要子级的高度,但这仍然可能不起作用.

You could try adding an explicit height to the TD and using table-layout:fixed on the table. At least that way the browser knows the height of the parent without needing the height of the child but that still may not work.

您可能需要重新考虑如何处理此问题.

You might need to rethink how you go about this.

这篇关于获取表格以填充 td 中的 100% 高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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