Div实现input垂直居中 兼容ie7,ie8,ff?
代码:<style type="text/css">
body{font-size:12px;}
.lanrentuku1{
border: 1px solid #CCC;
width:1120px;
height:40px;
margin:auto;
display: table;
*position: relative;
overflow: hidden;
}
.lanrentuku2 {
vertical-align: middle;
display: table-cell;
*position: absolute;
*top: 50%;
}
.lanrentuku3 {
*position: relative;
*top: -50%;
float:right;
padding-right:10px;
}
</style>
<body><br /><br /><br />
<div class="lanrentuku1">
<div class="lanrentuku2">
<form action="search.php" name="formsearch">
<div class="lanrentuku3">
<input name="textfield" type="text" size=”30”>
</div></form>
</div></div>
</body>
代码:<style type="text/css">
body{font-size:12px;}
.lanrentuku1{
border: 1px solid #CCC;
width:1120px;
height:40px;
margin:auto;
display: table;
*position: relative;
overflow: hidden;
}
.lanrentuku2 {
vertical-align: middle;
display: table-cell;
*position: absolute;
*top: 50%;
}
.lanrentuku3 {
*position: relative;
*top: -50%;
float:right;
padding-right:10px;
}
</style>
<body><br /><br /><br />
<div class="lanrentuku1">
<div class="lanrentuku2">
<form action="search.php" name="formsearch">
<div class="lanrentuku3">
<input name="textfield" type="text" size=”30”>
</div></form>
</div></div>
</body>
本文介绍了如何使用CSS技巧在Div元素中垂直居中输入框,兼容IE7、IE8及Firefox浏览器。
9328

被折叠的 条评论
为什么被折叠?



