网页居中问题

尚方宝剑彤叟无欺 2010-02-04 03:10:00
编了一个ASP.NET系统,设置了所有网页居中,在遨游和IE6中能够居中,为什么到了IE8里不能居中,有什么办法能在IE8中居中显示。那位能提供方法,谢谢了!
...全文
197 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
楼上的好复杂的方法,看我的解决方案。不过还是要谢谢你。
彦然软件 2010-02-05
  • 打赏
  • 举报
回复
不好意思,应该这样子来!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>标题 </title>
</head>
<body>
<div style="width:500px;height:600px;margin-left:auto;margin-right:auto;margin-top:50px;text-align:center;border:1px solid;">
<p>Hello HTML!<br />
这里啊 !<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></p>
<p>没有这句话不起作用的,标准问题。</p>
<p><div style="margin-left:auto; margin-right:auto; border:1px solid #003300"></p>
<p>HTML</p>
<p></div><br />
</p>
这样子才起作用!
</div>
<script language=javascript>
alert("注意头部文件");
</script>
</body>
</html>
  • 打赏
  • 举报
回复
问题解决,可惜楼上没有提供正确答案的。在<head>标签中加入以下语句:
在<head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> </head>
彦然软件 2010-02-05
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>标题</title>
</head>
<body>
<div style="width:500px;height:600px;margin-left:auto;margin-right:auto;margin-top:50px;text-align:center;border:1px solid;">
Hello HTML!
</div>
<script language=javascript>
alert("注意这里<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">");
</script>

</body>
</html>
  • 打赏
  • 举报
回复
加上style="margin:0 auto",也不管用呀,咋回事?
随风落梦 2010-02-04
  • 打赏
  • 举报
回复
style="margin:0 auto"这样就可以了
baishi1987 2010-02-04
  • 打赏
  • 举报
回复
LS正解
Specialaspnet 2010-02-04
  • 打赏
  • 举报
回复

margin:0 auto

这样就可以了啊..
flyerwing 2010-02-04
  • 打赏
  • 举报
回复
<div style="width:100%;margin:0px;padding:0px;text-align:center;">
.....
</div>
  • 打赏
  • 举报
回复
<div style="margin:0 auto;width:600px">alsdfjlasfj</div>
这样就能居中了
margin:0 auto意思是上下为0,左右自动(边距)

62,254

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧