有<input type="text" />
我需要设置输入文本的垂直对齐方式.例如中间或顶部.
http://jsfiddle.net/eSPMr/
j08*_*691 21
使用填充伪造它,因为vertical-align对文本输入不起作用.
CSS
.date-input {
width: 145px;
padding-top: 80px;
}?
Run Code Online (Sandbox Code Playgroud)
另一种方法是使用line-height
:http:
//jsfiddle.net/DjT37/
.bigbox{
height:40px;
line-height:40px;
padding:0 5px;
}
Run Code Online (Sandbox Code Playgroud)
当您需要特定高度时,这往往更加一致,因为您不需要根据字体大小和所需高度等计算填充.
input[type=text]
{
height: 15px;
line-height: 15px;
}
Run Code Online (Sandbox Code Playgroud)
这是设置垂直 - 中间位置的正确方法.