表位文本css [重复]

问题描述 投票:0回答:4

这个问题在这里已有答案:

我希望我的文字在第3个单元格的左上角。

这是我的例子:http://jsfiddle.net/24nd5/

<table border="1" style="width: 100%;">
<tr>
    <td style="width: 15%;">
        lol lol lol lol lol
        lol lol lol lol lol
        lol lol lol lol lol
        lol lol lol lol lol
    </td>
    <td style="width: 3%;">

    </td>
    <td style="">
        Name
    </td>
</tr>
</table>
html css text html-table position
4个回答
2
投票

为了使其更具动态性,您可以添加:

table tr td:last-child  { vertical-align:top; }

要么

table tr td:nth-child(3) { vertical-align:top; }

Fiddle here

现在,如果你添加更多的行每个最后一个单元格(或第三个取决于你从上面使用的代码)将左上角的文本

Fiddle here


3
投票

请在上一个<td>中添加此内联CSS

vertical-align:top;

这是更新的演示链接。

Demo


2
投票

这很简单,只需添加vertical-align:top;到原因的<td>


1
投票
<td style="text-align:left; vertical-align:top">
    Name
</td>
© www.soinside.com 2019 - 2024. All rights reserved.