css样式让input垂直居中

时间:2021-12-10 05:21:25

css样式让input垂直居中

css代码:

 .div1{
border: 1px solid #CCC;
width:1120px;
height:40px;
margin:auto;
display: table;
*position: relative;
overflow: hidden;
}
.div2 {
vertical-align: middle;
display: table-cell;
*position: absolute;
*top: 50%;
}
.div3 {
*position: relative;
*top: -50%;
float:right;
padding-right:10px;
}

html代码:

<div class="div1">
<div class="div2">
<div class="div3">
<input type="text" size="30">
</div>
</div>
</div>