我想把注册表单放在页面中央。
请告诉我应该如何实现。
<div style="width:400px; margin-right:auto; margin-left:auto; border:1px solid #000;">
<form action="helloWorld">
<Some markup>
</form>
</div>
<div style="margin:0 auto" align=center>
<input button>
</div>
form {width: 40%;
margin-right: 30%;
margin-left: 30%;
background-color: green}
div.mainform {width:100%;
border:1px solid #000}
<DIV ID="MAINFORM">
<FORM>
Other HTML Markup
</FORM>
</DIV>
margin:0px auto;
- mauristext-align:center
来正确地将它居中在页面上,仅仅将边距设置为自动是不够的。 - James Goodwinmargin: 10px auto 0 auto;
,这将产生相同的效果,但页面顶部会多出一些空间。 - James Goodwin