2013-02-06 56 views
0

首先;我在這裏和網上搜索了這個,但找不到一個可行的解決方案。我現在正在處理這個問題兩天了,所以我必須問。TD高度在Internet Explorer中的動態內容上擴展

我以下的問題:

<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

左上角和中間左單元格的內容動態地被通過的Javascript修改後正在擴大。

我想它確實有一些做的文檔類型,但我不是專家。

有使Internet Explorer和Firefox的辦法不僅擴大了左下細胞;上面的另外兩個單元應該保持原樣。

需要幫助。

回答

0

看吧同樣的問題:IE setting row height not working when using rowspan

我想一個解決方案將是改變過去的表山坳德高度更新添加的內容後,根據總高度後的內容 - 10 PX?

+0

將嘗試... – MehmetGunacti

+0

任何想法如何獲得動態添加內容後的表的高度?我試過document.getElementById(「content」),style.height和變體,但不能使它工作。 – MehmetGunacti

+0

解決: 我不能確定內容添加純JavaScript後的高度。所以我用的jQuery代替: $( 「#theRed」)的CSS( 「高度」,$( 「#內容」),高度() - 10)。 ( 'theRed' 是左下小區的ID)。 非常感謝,Techmonk! – MehmetGunacti

0

所以前兩個單元格必須只爲5px高?在FF上它可以起作用,如果你從第三個TD刪除高度:100%。

編輯:在最後一個div爲640px:OK形成我,如果不是100%我寫高度還挺工作。既然你知道表的總高度是650px,那麼它不應該是一個問題。

+0

OK對不起,不是在IE9。我會盡力解決這個問題。 – nowhere

+0

事實上,我說的是100%的高度,它也適用於FF。卜IE問題依然存在。 – MehmetGunacti

+0

它適用於我ie9通過設置5px,5px和640px的三個div – nowhere

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

只對IE做進一步以此爲刪除高度:在其他瀏覽器100%的作品