我有一個關於可用性/設計的問題。 我目前正在使用一些JQuery來隱藏/顯示整個區域。目前這些都在一張大桌子上,頂部有一個thead作爲主標題,然後是第二個thead,它是所顯示內容的標題。接下來是另一個thead,它是在tbody中顯示的任何被隱藏的標題。 我知道這是可怕的風格,但我想克服的問題是我希望所有行都相同,因爲它們都顯示相同類型的數據。多個thead/tbody設計
代碼示例
<table id="report">
<thead>
<tr id="header">
<th>Country</th>
<th>Population</th>
<th>Area</th>
<th>Official languages</th>
<th></th>
</tr>
</thead>
<thead>
<tr>
<td>United States of America</td>
<td>306,939,000</td>
<td>9,826,630 km2</td>
<td>English</td>
<td><div class="arrow"></div></td>
</tr>
</thead>
<thead>
<tr>
<td>First Row</td>
<td>Second Row</td>
<td>Third Row</td>
<td>Fourth Row</td>
<td>Fifth Row</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="5">
<img src="../125px-Flag_of_the_United_States.svg.png" alt="Flag of USA" />
<h4>Additional information</h4>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Usa">USA on Wikipedia</a></li>
<li><a href="http://nationalatlas.gov/">National Atlas of the United States</a></li>
<li><a href="http://www.nationalcenter.org/HistoricalDocuments.html">Historical Documents</a></li>
</ul>
</td>
</tr>
<tr><td>some other stuff</td></tr>
</tbody>
</table>
下面就是將顯示: alt text http://img694.imageshack.us/img694/9773/screenshot20100708at100.png alt text http://img822.imageshack.us/img822/9206/screenshot20100708at101.png
現在我之所以實際上是由這種方式,是因爲通常我都會有4行的實際可顯示標題(這個例子是國家數據),只有3個標題欄被隱藏(第一行,第二行等)。這裏面的數據有1行是一個URL,可以是從10個字符到100+(100+是常見的)的任何地方,這導致整個顯示改變並且我的標題變爲2或3行。雖然我想讓所有行保持不變,但有什麼方法可以將表中的1個tbody與1個thead關聯起來,這樣它就不會影響其他任何其他行。由於這可能會讓人困惑,因爲實際上有多個表格的更好的方法,但是每個表格的副本都保持不變,而不管輸入的數據是什麼。 我知道會有問題,但任何幫助將不勝感激,並注意我完全打開做這個不同的方式。然而,需要的是,數據可以隱藏起來,並且會有一個表格,並且會有一個信息頭。可以有一個不需要匹配的可顯示部分(它可能是一個div),每個部分內部的數據應該保持相同的格式。
PS:如果以下感興趣的是我用於整個事情的JQuery。
<script type="text/javascript">
$(document).ready(function(){
$("#report thead").children("tr:odd").not("#header").addClass("odd");
$("#report thead").children("tr:odd").not("#header").each(function(index){$(this).attr("id", "id" + index);});
$("#report thead").children("tr:even").not("#header").addClass("bodyhead");
$("#report thead:even").not(":first-child").each(function(index){$(this).attr("id", "bhid" + index);});
$("#report tbody").each(function(index){$(this).attr("id", "bid" + index);});
//$("#report tbody").each(function(index){$(this).attr("id", "id" + index);});
//$("#report tbody").children("tr:not(.odd)").hide();
$("#report tbody").hide();
$("#report thead:even").not(":first-child").hide();
//$("#report tbody #id0").show();
//For header of headers.
$("#report thead").children("tr:first-child").show();
$("#report thead").children("tr").not("#header").not(".bodyhead").click(function(){
$("#report #b" + this.id).toggle();
$("#report #bh" + this.id).toggle();
$(this).find(".arrow").toggleClass("up");
});
});
</script>
是否有一些在線引用或文章詳細解釋了'table-layout:auto'和'table-layout:fixed'之間的區別?找不到這兩個用例的穩定和清晰的解釋,發現這個https://css-tricks.com/fixing-tables-long-strings/,但它只顯示示例,沒有詳細解釋發生了什麼。 – tonix 2015-11-25 07:11:19