2009-10-29 71 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。

相關問題