表单宽高不固定情况下,表单外面加一个父标签fa 表单加一个类centered
<body><div class="fa">
<form name="search" method="post" action="#" class="centered">
<input value="请输入关键词" type="text" name="q" />
<input type="submit" value="搜索"/>
</form>
</div>
</body> 清除页面默认样式后(margin padding)
<style type="text/css">
html,body{width: 100%height: 100%}
.fa {text-align: centerheight: 100%}
.fa:before {content: ''display: inline-blockheight: 100%vertical-align: middle}
.centered {display: inline-blockvertical-align: middlebackground: redwidth: auto}
</style>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)