<br>
标记在另一个标记内的行为的问题。 我正在做这个表格,其中<thead>
内有两个<th>
:其中一个是&#34; name&#34; 另一个&#34;姓氏&#34; 。在&#39; 和&#39; name&#39; 之间插入<br>
以显示第二个<th>
两条线,避免更长的单元格宽度。
现在&#34;姓氏&#34; 显示在两行中,<th>
中的文字都没有从相同的高度开始。
我希望&#34; name&#34; <th>
中的文字以与&#34;姓氏&#34;相同的高度开始。 <th>
。
<th>NAME <br> </th>
不执行任何操作。<th>NAME <br> .</th>
会执行所需的换行符。为什么会这样?
如果空格不在标记之间,那么它们是否应该被视为内容,从而激活<br>
善良?
如何在&#34; name&#34; <th>
中实现两行,而在第二行没有不必要的字符,或者不必使用CSS设置样式?
检查html并启发我
<html>
<body>
<table border="2px">
<thead>
<th>NAME <br> </th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
<br>
<table border="2px">
<thead>
<th>NAME <br> .</th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
</body>
</html>
&#13;
我很好奇<br>
在另一个标签内时的有缺陷的行为。
答案 0 :(得分:0)
您可以尝试在它们之间放置一个
,它们应该能够满足您的需求。
<th>NAME <br> </th>
或者你可以关闭br标签,这应该适用于
<th>NAME <br /> </th>
答案 1 :(得分:0)
使用style="vertical-align:top;"
或valign="top"
将其对齐顶部
<html>
<body>
<table border="2px">
<thead>
<th valign="top">NAME</th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
<br>
<table border="2px">
<thead>
<th style="vertical-align:top;">NAME</th>
<th>LAST<br>NAME</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
</body>
</html>
&#13;