【问题标题】:If I have text in a cell within a table, how can I add text to the same cell just aligned to the far right of the cell?如果表格中的单元格中有文本,如何将文本添加到与单元格最右侧对齐的同一单元格中?
【发布时间】:2021-01-01 14:59:24
【问题描述】:

如果表格内的单元格中有文本(自动左对齐,这很好),我怎样才能将文本添加到与该单元格最右侧对齐的同一个单元格中?

例如,下面的 HTML 代码,我需要在当前读取 "<td>Ctrl ⌘ N</td>" 的单元格的最右侧添加一个星号。我该怎么做?

<table class="shortcutTable">
  <tbody>
    <tr>
      <th class="narrow" lang="en">Shortcut</th>
      <th lang="en">Action</th>
    </tr>
    <tr>
      <td>Ctrl ⌘ N</td>
      <td lang="en">Quick Note</td>
    </tr>

【问题讨论】:

    标签: html css html-table row cell


    【解决方案1】:

    CSS 浮动属性会做你想做的事。如果您的页面中已经链接了一个 CSS 文件,您可以为它创建一个类,但如果您只想将它​​与 HTML 一起放入,请尝试:

    <td>Ctrl ⌘ N<span style="float: right">&ast;</span></td>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-08
      • 1970-01-01
      • 2010-12-14
      • 1970-01-01
      • 2012-11-07
      • 1970-01-01
      • 2014-09-20
      相关资源
      最近更新 更多