html将表单居中的方法:首先表单外面加一个父标签fa;然后表单加一个类centered,代码为【
<form name=”search”method=”post” action=”#” class=“”“】。

本教程操作环境:windows7系统、html5版,DELL G3电脑,该方法适用于所有品牌电脑。
html将表单居中的方法:
表单宽高不固定情况下,表单外面加一个父标签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: center;height: 100%;}
.fa:before {content: '';display: inline-block;height: 100%;vertical-align: middle;}
.centered {display: inline-block;vertical-align: middle;background: red;width: auto;}
</style>
相关学习推荐:html教程
以上就是html怎样将表单居中的详细内容,更多请关注其它相关文章!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
