【问题标题】:Table position text css [duplicate]表格位置文本css [重复]
【发布时间】:2014-02-24 09:17:18
【问题描述】:

我想让我的文本在第三个单元格的左上角。

这是我的例子: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


【解决方案1】:

请在您的最后一个 &lt;td&gt; 中添加这个内联 CSS

vertical-align:top;

这是更新后的演示链接。

Demo

【讨论】:

  • 感谢您的回答@Kheema Pandey!
  • 您好 Zak,您应该检查绿色标记,以便其他人知道哪个答案更准确。否则对于正在寻找相同答案的用户来说会更加混乱。
  • 如果您只想将其应用于第三个单元格,您可以使用伪选择器:last-child
【解决方案2】:

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

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

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

Fiddle here

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

Fiddle here

【讨论】:

    【解决方案3】:

    这很简单,只需将 vertical-align: top; 添加到 &lt;td&gt; 中即可。

    【讨论】:

      【解决方案4】:
      <td style="text-align:left; vertical-align:top">
          Name
      </td>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-05-08
        • 2019-08-10
        • 1970-01-01
        • 2011-02-04
        • 1970-01-01
        • 2011-08-09
        • 1970-01-01
        相关资源
        最近更新 更多