100%td内的100%高度div [英] 100% height div inside 100% td

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

问题描述

好吧,
所以这里是我的问题..和它的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>


解决方案

div上的边框是'external '的高度...所以,真正的,你应用的风格是100%+ 2px(1px顶部边框,1px底部边框)的高度...



如果你删除边框的真实高度将是100%,滚动条应该消失:)



如下所述, height:100%在底部单元格中使总表格高度=第一行高度+底部行高度的100%。






更新:好吧,所以它不漂亮,但它是我得到的最好的:

如果您要给div一个 blah

的标识, code>并使用下面的jquery来破解div的高度,使其与父母的高度一致......这确实需要第一行/单元格的高度定义,尽管..我设置为100px为例。

  $('#blah')。height($('#blah')。parent()。height()); 



jsfiddle示例... http://jsfiddle.net/Damien_at_SF/vwcvN/


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>

解决方案

The border on the div is 'external' to the height... So really, the style you are applying is a height of 100% + 2px (1px top border, 1px bottom border)...

If you remove the border the true height will be 100% and the scroll bar should disappear :)

As commented below, the height:100% in the bottom cell makes the total table height = first row height + the 100% of the bottom row height.


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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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