如何让DIV垂直居中 <BODY><TABLE height="100%"><TR> <TD> <div> aaaaaaaaaaaa </div> </TD></TR></TABLE></BODY> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><style>#center { background: #090; width: 100px; height: 96px; position: relative; left: 50%; margin-left: expression(-(this.offsetWidth/2)+"px"); margin-top:20%;}</style><div id='center'></div> <div><table width=100% height=100%><tr><td></td></tr></table></div> DIV+TABLE不好吧,还是直接用CSS实现吧。------------------------------------------酷得组件仓库 - 第三方软件开发组件下载\试用www.cookcode.net 通常在ie和ff下是两种方式。<style>/**我是考虑到层的高度,设为百分之43*/.myDiv{ position: fixed; top: 43%; left: 50%; margin-left: -300px; width:500px; border: 1px solid #93a6aa; background-color:#dfe6ed; padding: 10px;}* html .myDiv{ position: absolute; width:600px; top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(43 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px');}</style><div class="myDiv"> 这个居中了没有?</div> http://www.blueidea.com/tech/web/2006/3231.aspCSS实现完美垂直居中 这个这样子写可能更好一点。<style> #center { background: #090; width: 100px; height: 96px; position: relative; margin:20% auto auto;} </style></head><body><html> <div id='center'> fffffff</div></body></html> <style> #div1 { position: absolute; width:100px; height:50px; left:50%; top:50%; margin-left:-50px; margin-top:-25px; border:1px solid #000} </style> <body> <div id="div1"></div> </body> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style>.dd { width:300px; height:30px; margin:0px auto; border:1px solid #000000 }</style></head><body><div class="dd"></div></body></html> body 设置高度 相对 绝对都可以然后各区块就可以设定高度了 PHP怎么采集AJAX加载的内容,高人指点下思路,谢谢 php新手求救 PHP常用代码 php如何以root身份执行 知道Paypal支付这块帮帮忙!在线等。。。 小程序 变量不识别怎么弄?? 通过strtotime函数得到当月第一天0点的时间为何错误? 是不是php中的bug呀,好郁闷 求助:请大家帮我看看这段代码的问题出在什么地方? 后台转义字符问题 phpmyadmin 里遇到的问题:#1364 - Field 'ssl_cipher' doesn't have a default value php中截取含有html代码的字符串问题???
<style>
#center {
background: #090;
width: 100px;
height: 96px;
position: relative;
left: 50%;
margin-left: expression(-(this.offsetWidth/2)+"px");
margin-top:20%;}
</style>
<div id='center'>
</div>
酷得组件仓库 - 第三方软件开发组件下载\试用
www.cookcode.net
<style>
/**我是考虑到层的高度,设为百分之43*/
.myDiv{
position: fixed;
top: 43%;
left: 50%;
margin-left: -300px;
width:500px;
border: 1px solid #93a6aa;
background-color:#dfe6ed;
padding: 10px;
}
* html .myDiv{
position: absolute;
width:600px;
top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(43 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px');
}
</style>
<div class="myDiv"> 这个居中了没有?</div>
CSS实现完美垂直居中
<style>
#center {
background: #090;
width: 100px;
height: 96px;
position: relative;
margin:20% auto auto;
}
</style>
</head><body>
<html>
<div id='center'>
fffffff
</div>
</body>
</html>
#div1 {
position: absolute;
width:100px;
height:50px;
left:50%;
top:50%;
margin-left:-50px;
margin-top:-25px;
border:1px solid #000
}
</style>
<body>
<div id="div1"></div>
</body>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
.dd { width:300px; height:30px; margin:0px auto; border:1px solid #000000 }
</style>
</head><body>
<div class="dd"></div>
</body>
</html>