html - 将 <td> 中的文本输入与 twitter bootstrap 中的右侧对齐?

标签 html css twitter-bootstrap twitter-bootstrap-3 html-table

我正在尝试将文本输入右对齐,但由于某种原因它没有这样做。

我用过style="text-align: right"<td>

看例子:

https://jsfiddle.net/DTcHh/31200/

代码

<table class="table">
  <thead>
    <tr>
      <th>Field 1</th>
      <th style="text-align:right">Field 1</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Text 1</td>

      <td style="text-align: right">
        <div class="form-group" style="text-align: right">
          <input style="width:60px" type="number" class="form-control" value="test">
        </div>
      </td>
    </tr>
  </tbody>
</table>

最佳答案

不需要额外的 CSS 只需使用 Bootstrap pull-right:

https://jsfiddle.net/cp1tvuj3/

<div class="form-group">
          <input style="width:60px" type="number" class="form-control pull-right" value="test">
</div>

Updated fiddle

text-right 将不起作用,因为 form-controldisplay: block

最初的问题是针对 Bootstrap 3 的。在 Bootstrap 4 中,pull-right is now float-right .

关于html - 将 <td> 中的文本输入与 twitter bootstrap 中的右侧对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42976642/

相关文章:

css - box-decoration-break 的替代品

html - 在另一个中心 div

twitter-bootstrap - Bootstrap中如何判断列宽?

html - Bootstrap ~ "aria-expanded"元素 <a> 不接受

javascript - 如何加载文件并查看其内容?

html - 找不到更正我的输入文本框的方法

javascript - 鼠标悬停图像到具有透明背景的文本

javascript - ID 中的空格并将变量放入 ID jquery

css - 没有这样的文件或目录 - datetimepicker.css

jquery - 固定 Bootstrap 导航栏下的模糊效果