Html 如何使html表中的td(单元格)扩展为一行以适合一行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10853763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make td (cell) from html table expand for the row to fit in one line?
提问by aF.
In some html cells (td) the text is wrapped because the size of the column is smaller than the size of the text on the cell. I don't want the text to be wrapped, I want the column width to expand so the wrapping don't happen!
在某些 html 单元格 (td) 中,文本被换行,因为列的大小小于单元格上文本的大小。我不希望文本被换行,我希望列宽扩大,这样就不会发生换行!
How can I do that?
我怎样才能做到这一点?
One final note, I only can use html code, no css :(
最后一点,我只能使用 html 代码,不能使用 css :(
回答by j08691
Since you can't use CSS, how about:
既然你不能使用 CSS,那么如何:
<td nowrap="nowrap">
I'd prefer to use CSS here on the TD (white-space:nowrap) since the nowrap attribute on the TD element isn't supported HTML 4.01 Strict / XHTML 1.0 Strict.
我更喜欢在 TD (white-space:nowrap) 上使用 CSS,因为不支持 TD 元素上的 nowrap 属性 HTML 4.01 Strict / XHTML 1.0 Strict。
Here's a quick jsFiddle exampleshowing the effect. Take out the attribute and you can see the difference.
这是一个显示效果的快速jsFiddle 示例。取出属性,就可以看出区别了。
回答by Josh Siok
Confusing question, but I think you might be looking for the colspan="x" attribute.
令人困惑的问题,但我认为您可能正在寻找 colspan="x" 属性。
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td colspan="2">fills both columns</td>
</tr>
</table>