2009-10-29 29 views
0

看50%的高度,在此代码:如何设置为WebKit的表格单元格器(Chrome,Safari浏览器)

<html> 
<body> 
    <table border="1px"> 
     <tr> 
      <th align="center" width="70px">Name</th> 
      <th align="center" width="70px">State</th> 
      <th align="center" width="70px">Enabled</th> 
      <th colspan="2">Date &amp; Time</th> 
      <th>Message</th> 
     </tr> 
     <tr> 
      <td rowspan="2"> 
       <span>Import</span> 
      </td> 
      <td rowspan="2" align="center"> 
       Idle 
      </td> 
      <td rowspan="2" align="center"> 
       Yes 
      </td> 
      <td style="width:150px;">Start:</td> 
      <td style="width:150px">28.10.2009 00:00:00</td> 
      <td rowspan="2"> 
       The job succeeded. The Job was invoked by User sa. The last step to run was step 1 (Updating).The job succeeded. The Job was invoked by User sa. The last step to run was step 1 (Updating).The job succeeded. The Job was invoked by User sa. The last step to run was step 1 (Updating).The job succeeded. The Job was invoked by User sa. The last step to run was step 1 (Updating). 
      </td> 
     </tr> 
     <tr> 
      <td>Schedule:</td> 
      <td>28.10.2009 13:41:37</td> 
     </tr> 
    </table> 
</body> 

串的高度,包含启动和时间表是需要的是平等的。在IE中,Firefox默认情况下具有相同的高度。使用CSS可以为WebKit实现相同的功能吗?怎么样? (禁止高度硬编码,动态生成消息大小。)

回答

1

高度有什么问题:50%? (周围的桌子,身体和HTML然后需要高度:100%为好。)

+0

好的,我需要在哪放置表格的容器?以及如何设置它的高度? – 2009-10-29 15:11:52

0

这会做你想要什么:

<html> 
<body> 

<table border="1" style="height:100%; width:100%;"> 
    <tr style="height:6%;"> 
    <th align="center" style="width:70px;">Name</th> 
    <th align="center" style="width:70px;">State</th> 
    <th align="center" style="width:70px;">Enabled</th> 
    <th align="center" colspan=2>Date &amp; Time</th> 
    <th align="center" style="width:70px;">Message</th> 
    </tr> 
    <tr> 
    <td align="center" rowspan=2>Import</td> 
    <td align="center" rowspan=2>Idle</td> 
    <td align="center" rowspan=2>Yes</td> 
    <td style="height:47%; width:150px;">Start:</td> 
    <td style="height:47%; width:150px;">28.10.2009 00:00:00</td> 
    <td rowspan=2 style="height:100%; wifth:70px;">The job succeeded. The Job was invoked by User sa. The last step to run was step 1 (Updating).The job succeeded. The Job was invoked by User sa. The last step to run was step 1 (Updating).The job succeeded. The Job was invoked by User sa. The last step to run was step 1 (Updating).The job succeeded. The Job was invoked by User sa. The last step to run was step 1 (Updating). 
    </td> 
    </tr> 
    <tr> 
    <td>Schedule:</td> 
    <td>28.10.2009 13:41:37</td> 
    </tr> 
</table> 

</body> 
</html> 

一些浏览器将采取height=50%意味着高度应为50%作为一个整体,所以我将<td>高度设置为每个47%,将高度设置为6%。所有流行的浏览器中仍然存在一个错误,除了IE(令人惊讶的),其中表格不会正常调整大小。具体来说,当浏览器窗口的宽度减小时,它们将使两个ed单元格的底部更高,并且最上面的单元格更短。尽管如此,你应该可以使用这些数字,并使它们适合你的需求。如果不是,您可以考虑查看div s而不是table s。

相关问题