Html 我想将 <td> 中的文本与顶部对齐
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5671687/
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
I want to align the text in a <td> to the top
提问by Buffon
I have the following code
我有以下代码
<table style="height: 275px; width: 188px">
<tr>
<td style="width: 259px;">
main page
</td>
</tr>
</table>
The main page appears in the center of the cell I want it to appear at the top.
主页出现在我希望它出现在顶部的单元格的中心。
回答by thirtydot
https://developer.mozilla.org/en/CSS/vertical-align
https://developer.mozilla.org/en/CSS/vertical-align
<table style="height: 275px; width: 188px">
<tr>
<td style="width: 259px; vertical-align:top">
main page
</td>
</tr>
</table>
?
?
回答by Vik David
Add a vertical-align
property to the TD, like this:
vertical-align
向 TD添加一个属性,如下所示:
<td style="width: 259px; vertical-align: top;">
main page
</td>
回答by Jay
Use <td valign="top" style="width: 259px">
instead...
使用<td valign="top" style="width: 259px">
,而不是...
回答by Faraz Ahmad Ramish
you can use valign="top"
on the td tag it is working perfectly for me.
你可以valign="top"
在 td 标签上使用它对我来说非常完美。
回答by Basheer AL-MOMANI
I was facing such a problem, look at the picture below
我正面临这样的问题,请看下图
and here is its HTML
这是它的 HTML
<tr class="li1">
<td valign="top">1.</td>
<td colspan="5" valign="top">
<p>How to build e-book learning environment</p>
</td>
</tr>
so I fix it by changing valign Attributein both td
tags to baseline
所以我通过将两个标签中的valign 属性更改td
为baseline
and it worked
它起作用了
hope this help you
希望这对你有帮助