< td>的宽度当我使用< br>< br>时,在一个固定的宽度< table>上。为什么? [英] Width of a <td> is narrower when I use a <br> in it on a fixed width <table>. Why?

查看:133
本文介绍了< td>的宽度当我使用< br>< br>时,在一个固定的宽度< table>上。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段HT​​ML代码片段(在使用严格doctype的有效文档中):

I have this HTML code fragment (in a valid document using strict doctype):

<p>Without &lt;br /&gt;</p>
<table border="1" width="220">
<tbody>
    <tr>
        <td>lorem</td>
        <td>ipsum</td>
        <td>lorem ipsum</td>
        <td>lorem</td>
        <td>ipsum</td>
    </tr>
</tbody>
</table>

<p>With &lt;br /&gt;</p>
<table border="1" width="220">
<tbody>
    <tr>
        <td>lorem</td>
        <td>ipsum</td>
        <td>lorem<br>ipsum</td>
        <td>lorem</td>
        <td>ipsum</td>
    </tr>
</tbody>
</table>

这在任何浏览器中都是这样呈现的:

This is rendered like this in any browser:

请注意,第三< TD>在第一个表格中更宽,这是因为我没有使用< br>在那里标记。否则这两个表的代码是相同的。

Please note that the third <td> is wider in the first table, only because I haven't used a <br> tag there. Otherwise the code for the two tables are identical.

我想找到一种方法让表格像第二个例子那样呈现,但不必使用a< br>标记。

I would like to find a way to have the table rendered like it is on the second example, but without having to use a <br> tag.

我无法指定单元格的宽度,因为它们可能包含任何数量的字符。

推荐答案

看起来像这是一个古老的问题/问题 - 很遗憾,我没有解决方案从2005年开始提供这个链接,证明有人在这个时候就已经在挣扎了。 :)

Seems like this is an ages old problem / question - unfortunately I have no solution to offer just this link from 2005 which proves that someone was struggling with this already even back then. :)

http://www.velocityreviews.com/forums/t162343-how-to-prevent-unnecessary-table-resizing.html

这篇关于&lt; td&gt;的宽度当我使用&lt; br&gt;&lt; br&gt;时,在一个固定的宽度&lt; table&gt;上。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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