HTML 垂直居中代码!

这个代码已经让我水平居中了,怎么样在让它垂直居中呢···不用CSS, 也就是说让这个登入框放在屏幕的最中间? 万分感谢····
<body bgcolor="#FF33FF">
<div align="center">
<form action="" method="">
登陆:<input type=""name="" /><br />
密码:<input type=""name="" /><br />
<input type="submit"name="" value="登陆"/>
<input type="reset"name="" value="取消"/>
<input type="button"name="" value="注册"/>
</form>

第1个回答  推荐于2017-09-19
<html>
<head>
<title>垂直水平居中层</title>
<style>
.divMain{
background-color:#ff00ff;
width:480px;/*(一定要设置这个值)*/
height:320px;/*(一定要设置这个值)*/
margin-left: auto;
margin-right: auto;
text-align:center;
vertical-align:middle;
/*想要两个滚动条的话就把下面的去掉*/
left:50%;/*FF IE7*/
top: 50%;/*FF IE7*/
margin-left:-240px!important;/*FF IE7 该值为本身宽的一半(一定要设置这个值)*/
margin-top:-160px!important;/*FF IE7 该值为本身高的一半(一定要设置这个值)*/
margin-top:0px;
position:fixed!important;/*FF IE7*/
position:absolute;/*IE6*/
_top: expression(eval(document.compatMode &&
document.compatMode=='CSS1Compat') ?
documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);/*IE5 IE5.5*/
}
form{margin-top:25%!important}
</style>
</head>
<body>
<div class="divMain">
<form action="" method="">
登陆:<input type=""name="" /><br />
密码:<input type=""name="" /><br />
<input type="submit" name="" value="登陆"/>
<input type="reset" name="" value="取消"/>
<input type="button" name="" value="注册"/>
</form>
</div>
</body>
</html>本回答被提问者采纳
第2个回答  2011-12-13
不使用css就难搞了。打几个<p>在div前面吧。
相似回答