当前第2页 返回上一页
表单宽高不固定情况下,表单外面加一个父标签fa,表单加一个类centered
1 2 3 4 5 6 7 8 | <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)
1 2 3 4 5 6 | <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页面跳转传递参数问题解答
一篇文章让你看懂Html基本规则和网页结构
Html中如何调整图片之间的间距
Html怎么使文本框不可编辑
Html的注释标记是什么
Html取消滚动条的方法
Html audio标签怎么用
Html方法是什么
Html中自定义菜单随着滚动条滑动的代码实现
更多相关阅读请进入《Html》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » html怎样将表单居中