固定高度和更改标题宽度(HTML表格)
问题描述:
我需要确保表格标题的高度是固定的,并根据标题单元格内容调整宽度。 (标题文本最多显示两行)我们如何使用样式来完成它?另外,我想确保表行的宽度与标题行的宽度相同(即标题行决定宽度)。固定高度和更改标题宽度(HTML表格)
注意:目前“交易部门所有者别名”排在前面。它需要分两行。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title><link href="Styles/TestStyle.css" rel="stylesheet" type="text/css" /></head>
<body>
<div id = "divForTransactionGrid">
<div>
<table cellspacing="0" rules="all" border="1" id="grdTransactions" style="border-collapse:collapse;">
<thead>
<tr>
<th scope="col">Transaction ID</th><th scope="col">Transaction Name</th><th scope="col">Transaction Owner</th><th scope="col">Transaction Department Owner Alias Name</th>
</tr>
</thead><tbody>
<tr>
<td>1</td><td>TR1</td><td>Lijo</td><td>Lijo</td>
</tr><tr>
<td>2</td><td>TR2</td><td>Lijo</td><td>This is a test value to test the result in real time scenario. Row width should be same as header width</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
CSS
#divForTransactionGrid
{
width: 300px;
height: 250px;
overflow:scroll;
}
答
你最大的问题是打破。 Transaction Department Owner Alias Name
让每一个空间“”突破到一个新行,但是Transaction Department Owner Alias Name
将迫使句呆在一起,仿佛一个字。
您所要做的就是让一个固定的空间留在您希望破坏的地方,然后使用您不希望破坏的地方,并且您将有2条或更少的地方。对于正好2行,请使用换行符<br>而不是空格“”。祝你好运。
你能花点时间修复一下问题空间吗? – Aristos 2012-04-02 15:14:36