Html 如何在顶部对齐表格单元格内容?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3565620/
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 align the table cells content on the top?
提问by aneuryzm
I have a HTML table. Each cell has content of different length.
我有一个 HTML 表格。每个单元格具有不同长度的内容。
For this reason, the content is not aligned on the top.
因此,内容未在顶部对齐。
I would like the first lines be aligned also in cells with few lines of text (the content should always start from the top).
我希望第一行也在具有几行文本的单元格中对齐(内容应始终从顶部开始)。
Instead the content is vertically centered in the middle.
相反,内容在中间垂直居中。
How can I fix this (a cross-browser solution.. working in I.E. as well)
我该如何解决这个问题(一个跨浏览器的解决方案......也可以在 IE 中工作)
Thanks
谢谢
回答by Tim
in css
在 CSS 中
td, th {
vertical-align:top;
}
回答by Vinay B R
use valign="top" on the td
在 td 上使用 valign="top"
<td valign="top">....</td>
setting the attribute on the tr should work for the entire row like wise for table
在 tr 上设置属性应该适用于整行,就像表格一样