I'l*_*ack 1 html css html-table twitter-bootstrap twitter-bootstrap-3
我试图将文本输入向右对齐,但由于某种原因它没有这样做。
我用 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>
Run Code Online (Sandbox Code Playgroud)
不需要额外的 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>
Run Code Online (Sandbox Code Playgroud)
text-right不会工作,因为form-control是display: block
最初的问题是针对 Bootstrap 3 的。在 Bootstrap 4 中,pull-right 现在是float-right。