我创建了一个HTML元素,供用户输入浮点数,并将输入分为两个输入元素,一个用于整数部分,另一个用于小数部分。我在两个输入文本元素之间添加了一个文本元素作为小数点,但它没有与两个输入元素的底部对齐,我不知道如何解决这个问题。这是我的代码片段:
我更新了代码后遇到了这个问题:
#whole {
text-align: center;
width: 25%;
margin-top: 10px;
box-sizing: border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing: border-box;
}
#decimal {
text-align: center;
width: 45%;
margin-top: 10px;
box-sizing: border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing: border-box;
}
#decimal_point {
vertical-align: bottom; /*align decimal point to bottom*/
}
<div>
<input type=text maxlength=1 id=whole name=whole value=>
<span id=decimal_point> . </span>
<input type=text maxlength=3 id=decimal name=decimal value=>
</div>
span
的line-height
调整为1.2
。这样应该就可以了。另一个选项是还可以垂直对齐input
元素。 - Bryan Elliott