为什么我的Bootstrap输入框不能向右对齐(=>请看带有placeholder='Does not align right'的第3个输入框)?
td表格元素具有定义对齐方式的样式...
当我从td元素中删除样式元素并将输入框样式text-align=right设置为右对齐时,它仍然是左对齐的。
td表格元素具有定义对齐方式的样式...
当我从td元素中删除样式元素并将输入框样式text-align=right设置为右对齐时,它仍然是左对齐的。
<div class="row">
<div class="col-md-6">
<div class="well" style="width:840px">
<table class='table borderless' style="width:800px">
<tr>
<td colspan="2">
<input class="form-control input-sm" style="width:300px;margin-bottom:0px" type="text" name="input1" placeholder="Input 1">
<input class="form-control input-sm" style="width:300px;margin-bottom:0px" type="text" name="input2" placeholder="Input 2">
</td>
</tr>
<tr>
<td colspan="2" style="text-align: right">
<input class="form-control input-sm" style="width:300px;margin-bottom:0px" type="text" name="input3" placeholder="Does not align right">
</td>
</tr>
<tr>
</table>
</div>
</div>
</div>
hr
。无论如何,这可能是出于类似的原因:hr
往往是一个块级元素,因此占据整个宽度。如果您设置了显式宽度,则实际可视化的行可能会变为100px
,但hr
元素所包含的块是全宽的,因此没有“文本对齐”的概念。 - Jeroenhr
的可视宽度将为100像素,但仍将占据其包含元素的全部宽度,因为剩余的宽度成为自动计算的margin
量。在 Chrome 或 FF 中使用开发者工具检查hr
,您将看到在设置特定宽度时添加的margin
。当宽度小于包含元素时,会添加此margin
。 - hungerstar