脚本宝典收集整理的这篇文章主要介绍了html怎样将表单居中,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
本教程操作环境: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怎样将表单居中的详细内容,更多请关注脚本宝典其它相关文章!
以上是脚本宝典为你收集整理的html怎样将表单居中全部内容,希望文章能够帮你解决html怎样将表单居中所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。