【问题标题】:Fixed Height and Changing Width for Header (HTML Table)标题的固定高度和更改宽度(HTML 表格)
【发布时间】:2012-04-16 05:47:07
【问题描述】:

我需要确保表格标题的高度是固定的,宽度是根据标题单元格内容调整的。 (标题文本最多显示两行)我们如何使用样式来做到这一点?另外,我想确保表格行的宽度与标题行的宽度相同(即标题行决定宽度)。

注意:目前“Transaction Department Owner Alias Name”排成一行。它需要分成两行。

<!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;

}

【问题讨论】:

  • 你能花点时间把问题的地方稍微修一下吗?

标签: javascript jquery asp.net html css


【解决方案1】:

你最大的问题是坏了。
Transaction Department Owner Alias Name
让每个空格 " " 换行,但是
Transaction&amp;nbsp;Department&amp;nbsp;Owner&amp;nbsp;Alias&amp;nbsp;Name
将迫使句子像一个单词一样保持在一起。

您所要做的就是在您希望它中断的地方留出一个常规空间,并在您不希望它中断的地方使用  's 并且您将拥有 2 行或更少的行。对于正好 2 行,请使用换行符
而不是换行符“”。祝你好运。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-14
    • 1970-01-01
    • 2018-09-05
    • 1970-01-01
    • 1970-01-01
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多