日期:2014-05-18  浏览次数:20526 次

ContentPlaceHolder 的高度问题,请指教啊
代码如下:

<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" style="height: 560px">
  <tr>
  <td bgcolor="#daedfe" style="width: 1001px" >
  <asp:ContentPlaceHolder ID="Counts" runat="server">
  </asp:ContentPlaceHolder>
  </td>
  </tr>
</table>

当我style="height: 560px"> 高度变化时,ContentPlaceHolder 高度不变,空出一部分来,很难看

怎么解决

------解决方案--------------------
取消固定高度.
------解决方案--------------------
取消固定高度.//同意
------解决方案--------------------
取消固定高度,用<div>的话,内容有多少就自己填充和收缩
------解决方案--------------------
1楼正解~!
------解决方案--------------------
取消ContentPlaceHolder的固定高度,如果ContentPlaceHolder里面是个iframe的话,可以使用js来自动调整iframe的高度

JScript code

function resizeIframe(){
    if(top.location != self.location){
        var frames = window.parent.document.getElementsByTagName('iframe');
        for (var i=0;i<frames.length;i++){
            if (frames[i].name == self.name){
                frames[i].height = document.body.scrollHeight;
                frames[i].width = document.body.scrollWidth;
                break;
            }
        }
    }
}
resizeIFrameHeight();

------解决方案--------------------
ContentPlaceHolder 设定高度为100%
------解决方案--------------------
<table width="100%" height=100% border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td bgcolor="#daedfe" >
<asp:ContentPlaceHolder ID="Counts" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
------解决方案--------------------
所以有时候还是
DIV布局来的省事
用DIV好了啊
------解决方案--------------------
表格有时候就是光出洋相,如上面的方法还是没解决,就用DIV做吧