问题描述
好吧,
所以这里是我的问题..和它的buggin我有一段时间...
i需要在这个TD里面设置下面的DIV 100%高度,没有任何副作用我的意思是滚动),因为一些未知的原因,当我把它设置为100%的高度,看起来像IE 8做了一些错误的计算..
我尝试了很多组合,但没有成功..
transitional
<!DOCTYPE html PUBLIC - / b
提前感谢您的帮助! / W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
< html xmlns =http://www.w3.org/1999/xhtml>
< style>
html,body
{
height:100%;
margin:0px;
padding:0px;
}
< / style>
< head>
< body>
< table style =height:100%border =1>
< tr>
< td> TOP< / td>
< / tr>
< tr style =height:100%>
< td style =height:100%>
< div style =border:1px dotted blue; height:100%> CONTENT< / div>
< / td>
< / tr>
< / table>
< / body>
< / html>
如果你删除边框的真实高度将是100%,滚动条应该消失:)
如下所述,
height:100%
在底部单元格中使总表格高度=第一行高度+底部行高度的100%。
更新:好吧,所以它不漂亮,但它是我得到的最好的:
如果您要给div一个 blah 的标识, code>并使用下面的jquery来破解div的高度,使其与父母的高度一致......这确实需要第一行/单元格的高度定义,尽管..我设置为100px为例。 $('#blah')。height($('#blah')。parent()。height());
jsfiddle示例...
Ok,so here is my problem.. and its buggin me for a while... i need to set the following DIV 100% height inside this TD without any side-effects (by that i mean scrolling), because for some unknown reason, when i set it to 100% height, looks like IE 8 does some wrong calculations..I tried a lot of combinations but no success..transitional doctype is required...thanks in advance for any help!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<style>
html, body
{
height:100%;
margin:0px;
padding:0px;
}
</style>
<head>
<body>
<table style="height:100%" border="1">
<tr>
<td>TOP</td>
</tr>
<tr style="height:100%">
<td style="height:100%">
<div style="border:1px dotted blue; height:100%">CONTENT</div>
</td>
</tr>
</table>
</body>
</html>
解决方案
UPDATE: okay, so its not pretty, but its the best i've got:
if you were to give the div an id of blah
and use the following jquery to hack the height of the div to that of it's parents... this does require a height definition for the first row/cell though.. i set at 100px for an example.
$('#blah').height($('#blah').parent().height());
jsfiddle example... http://jsfiddle.net/Damien_at_SF/vwcvN/
这篇关于100%td内的100%高度div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!