简体   繁体   English

TD高度扩展了Internet Explorer中的动态内容

[英]TD height expands on dynamic content in Internet Explorer

First; 第一; I've searched for this here and on the net, but couldn't find a working solution. 我已经在这里和网上搜索了此内容,但找不到有效的解决方案。 I'm working on this problem literally for two days now, so I have to ask. 从字面上看,我现在正在处理此问题两天,所以我不得不问。

I've following problem : 我有以下问题:

    <table width="650px" border="1" >
    <tr>
        <td style="height :5px">stay as you are</td>
        <td rowspan="3" id="content">
            empty
        </td>
    </tr>
    <tr>
        <td style="height :5px">please dont expand</td>
    </tr>
    <tr>
        <td style="background: red;height : 100%;">&nbsp;</td>
    </tr>
</table>
<input type="button" value="do" onclick="dontExpand()">
<script language="Javascript">
    function dontExpand() {
        var html = "";
        for (var i = 0; i < 100; ++i)
            html += "lorem ipsum<br>";
        document.getElementById("content").innerHTML = html;
    }
</script>

JSFiddle example of the problem, works only in Chrome 问题的JSFiddle示例,仅在Chrome中有效

The upper left and the left cell in the middle are expanding after the content dynamically gets modified by Javascript. 内容通过Javascript动态修改后,中间的左上和左单元格会扩展。

I guess it does have something to do with the DocTypes, but I'm no expert. 我想这确实与DocType有关,但是我不是专家。

Is there a way of making Internet Explorer and Firefox to only expand the lower left cell; 有没有一种方法可以使Internet Explorer和Firefox仅扩展左下方的单元格; the other two cells above should stay as they are. 上面的其他两个单元应该保持原样。

Need help please. 请需要帮助。

So the first two cells have to be only 5px tall? 那么前两个单元格必须只有5px高吗? On FF it works if you remove the height:100% from the third td. 在FF上,如果您从第三个td删除height:100%,则可以使用。

EDIT: OK form me it kinda works if instead of 100% i write height:640px on the last div. 编辑:好的,对我来说,如果不是在最后一个div上写height:640px,而不是100%的话,那还是可以的。 Since you know that the total height of the table is 650px then it shouldn't be a problem. 既然您知道表格的总高度为650px,那么这应该不是问题。

Look here same problem: IE setting row height not working when using rowspan 看这里同样的问题: 使用rowspan时,IE设置行高不起作用

I guess one solution will be to change teh height of the last table col after you update the content based on the total height after adding content - 10 px ? 我猜一个解决方案是在添加内容后,根据总高度更新内容后,更改最后一个表格col的高度-10像素?

var height = document.getElementById("content").offsetHeight; // to determine the content height.
table.style.height = height + 10 + "px";

Further do this only for IE as remove the height:100% works in other browsers 进一步仅对IE执行此操作,因为删除高度:100%在其他浏览器中有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM