繁体   English   中英

HTML将表格高度设置为100%

[英]HTML setting table height to 100%

我已经尝试过这样做,但是似乎只是被忽略了。 我发现有几篇文章说,如果要执行此操作,则必须确保父对象也是100%。 我有以下内容:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server" style="height:100%">
    <title>Untitled Page</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
      .MasterStyle
      {
          width: 98%;            
          height: 100%;
      }
      .ContentStyle
      {         
          width: 100%;
      }
      .TableStyle
      {
          width: 133px;                     
          height: 100%;
      }
    </style>
 </head>
 <body class="MasterStyle">
    <form id="frmMaster" runat="server">
     <div class="ContentStyle">        
      <asp:Label runat="server" Text="My Site Name" Font-Bold="true" Font-Names="MS-Sans" 
            Style="text-align:right" Width="100%" />
      <br />        
    </div>
    <hr />
    <table style="width:100%; height:100%" border="true">
      <tr>
        <td class="TableStyle" style="height:100%">    

我在桌子周围有一个边框,可以看到它没有填满高度。 谁能告诉我为什么我没有达到100%的身高?

我相信这也取决于浏览器,实现方式略有不同...
但也请尝试将<html>的高度设置为100%,因为它是<body>周围的元素。 层次结构是html > body > table ,如果最外面的元素未设置为100%,则内部的元素不能再变大。

编辑:
仔细查看您的源代码,我相信您的表实际上位于html > body > form > table ,因此也许您也需要将窗体高度设置为100%。 而且我注意到您的<head>设置为100%,最好删除它,因为<head>不属于表层次结构。 您永远不会为<head>设置高度会混淆渲染引擎...

暂无
暂无

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

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