2008-09-23 84 views
3

我無法讓td「Date」具有固定的高度。如果Body部分中的數量較少td Date元素比它應該大 - 即使我將Date高度設置爲10%並將Body height設置爲90%。有什麼建議麼?HTML中固定的TD高度屬性

<tr> 
    <td class="Author" rowspan="2"> 
    <a href="#">Claude</a><br /> 
    <a href="#"><img src="Users/4/Avatar.jpeg" style="border-width:0px;" /></a>   
    </td> 
    <td class="Date"> 
    Sent: 
    <span>18.08.2008 20:49:28</span> 
    </td> 
</tr> 
<tr> 
    <td class="Body"> 
    <span>Id lacinia lacus arcu non quis mollis sit. Ligula elit. Ultricies elit cursus. Quis ipsum nec rutrum id tellus aliquam. Tortor arcu fermentum nibh justo leo ante vitae fringilla. Pulvinar aliquam. Fringilla mollis facilisis.</span> 
    </td> 
</tr> 

而且我的CSS現在是:

table.ForumThreadViewer td.Date { 
    text-align: left; 
    vertical-align: top; 
    font-size: xx-small; 
    border-bottom: solid 1 black; 
    height: 20px; 
} 

table.ForumThreadViewer td.Body { 
    text-align: left; 
    vertical-align: top; 
    border-top: solid 1 black; 
} 

table.ForumThreadViewer td.Author { 
    vertical-align: top; 
    text-align: left; 
} 

它的工作爲FF但不是IE瀏覽器。 :(

+0

請發表你的CSS以及因此有人能幫助你。 – Haabda 2008-09-23 19:31:25

回答

2

奧利是對的!給你張貼的截圖,你正在使用錯誤的標記。你可以使用更多的東西是這樣的:用CSS

<div class="post"> 
    <div class="author"> 
    <a href="#">Claude</a><br /> 
    <a href="#"><img src="Users/4/Avatar.jpeg" /></a>   
    </div> 
    <div class="content"> 
    <div class="date">Sent: 18.08.2008 20:49:28</div> 
    <div class="body"> 
     This is the content of the message. 
    </div> 
    </div> 
    <div class="clear">&nbsp;</div> 
</div> 

這樣的:

div.post { 
    border: 1px solid #999; 
    margin-bottom: -1px; /* collapse the borders between posts */ 
} 
div.author { 
    float: left; 
    width: 150px; 
    border-right: 1px solid #999; 
} 
div.content { 
    border-left: 1px solid #999; 
    margin-left: 150px; 
} 
div.date { 
    border-bottom: 1px solid #999; 
} 
div.clear { 
    clear: both; 
    height: 0; 
    line-height: 0; 
} 
0

CSS

.Date { 
    height: 50px; 
} 
+0

適用於FF,但不適用於IE。 – rafek 2008-09-23 19:49:17

+0

不適用於IE,因爲IE會將其視爲最小高度。請參閱:http://stackoverflow.com/questions/56658/how-do-i-specify-in-html-or-css-the-absolute-minimum-width-of-a-table-cell#56738 – Prestaul 2008-09-24 03:36:44

0

我不完全明白你的問題,你說,如果你使用:

.Date { 
height: 10% 
} 
.Body { 
height: 90%; 
} 

.Date td是大於它應該是怎樣?你知道沒有設置絕對高度應該有多大?你是否考慮邊框和填充?

你可以嘗試加colspan="2"到(&nbsp;

6

當您使用百分比時,它們相對於它們的容器,即使如此,它只適用於某些類型的元素。我想這個工作,你需要將高度應用到<tr> s,並給<table>一個高度。如果<table>的高度也是相對的,你也需要給它的容器一個高度。

但看着你的數據,你真的肯定你應該使用一張桌子呢?!

+0

什麼不不工作?同意,這看起來不像我的表格數據! – roryf 2008-09-23 19:53:25