当前位置: 代码迷 >> ASP.NET >> .net中让网页正当中
  详细解决方案

.net中让网页正当中

热度:5577   发布时间:2013-02-25 00:00:00.0
.net中让网页居中
悲剧发生了 开始在页面中用margin:0 auto;设置页面居中 但是后面在IE8和FF中都不能够居中了,百度了一下找到一段这样的代码 据说能行 text-align:center; 但是效果令人差强人意,求一能让页面在所有浏览器中居中(兼容性。。。)经过测试的代码 谢谢。。。。

------解决方案--------------------------------------------------------
<body>
<div style="text-align:center;">
<div style="margin:0 auto;">
网站内容
</div>
</div>
</body>
------解决方案--------------------------------------------------------
没有完美的解决方案吧,只能具体情况具体处理之
------解决方案--------------------------------------------------------
<center></center>
------解决方案--------------------------------------------------------
目前我用的是这个,还可以,在多个浏览器都没问题:
<body>
<center>
这里是网页内容
</center>
</body>
------解决方案--------------------------------------------------------
固定宽度且居中.

------解决方案--------------------------------------------------------
不会布局 学习一下
------解决方案--------------------------------------------------------
#mainPage
{
margin:0px auto;
width:954px;
height: 911px;
max-height:1000px;
}
------解决方案--------------------------------------------------------
探讨
#mainPage
{
margin:0px auto;
width:954px;height: 911px;
max-height:1000px;
}

------解决方案--------------------------------------------------------
探讨
#mainPage
{
margin:0px auto;
width:954px;
height: 911px;
max-height:1000px;
}

------解决方案--------------------------------------------------------
body设置居中,然后内容放在一个DIV中,DIV固定宽度
C# code
  <body style="text-algin:center"><div style="width:980px; height:100%"></div></body>
------解决方案--------------------------------------------------------
<SCRIPT>
window.onload=function(){
w=400,h=400
window.resizeTo(w,h)
window.moveTo((screen.width-w)/2,(screen.height -h)/2)
}
</SCRIPT>

这种功能只能在IE中使用,其他浏览器限制使用这些方法的
  相关解决方案