固定高度和更改页眉的宽度(HTML表格) [英] Fixed Height and Changing Width for Header (HTML Table)

查看:164
本文介绍了固定高度和更改页眉的宽度(HTML表格)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to make sure that the height of the header of table is fixed and width is adjusted based on the header cell content. (Header text is displayed in maximum two rows) How can we do it using styles? Also, I want to make sure that the width of table rows is same as width of header row (i.e., header row determines width).

注意:目前,事务部门所有者别名。它需要两行。

Note: At present, "Transaction Department Owner Alias Name" comes in lines. It need to come in two lines.

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

}


推荐答案



交易部门所有者别名

允许每个空格换行符,但

交易& nbsp;部门& nbsp;所有者& nbsp;别名& nbsp;名称

将强制句子保持在一起如果单个单词。


所有你需要做的是留下一个常规的空间,你想要它打破,并使用& nbsp;',你不想它打破和你将有2条或更少的线。对于完全2行,使用换行符< br>而不是断开空间。祝你好运。

You biggest issue is breaking.
Transaction Department Owner Alias Name
lets each space " " break to a new line, however
Transaction&nbsp;Department&nbsp;Owner&nbsp;Alias&nbsp;Name
will force the sentence to stay together as if a single word.

All you have to do is leave one regular space where you want it to break, and use &nbsp;'s where you don't want it to break and you will have 2 or less lines. for exactly 2 lines, use a line break <br> instead of a breaking space " ". Best of luck.

这篇关于固定高度和更改页眉的宽度(HTML表格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆