日期:2014-05-18  浏览次数:20542 次

菜鸟请教:关于DIV居中的问题???
ASP.NET2.0(c#)   开发WEBFORM

假设电脑分辨率为1024X768  

现在我设置DIV的WIDTH   =   800PX,请问:如果使这个DIV在页面显示的时候居中??

请指点一下,谢谢!!!!

学习,关注!

------解决方案--------------------
<div style = "left:50%; position :relative ; margin-left:-400px ">
------解决方案--------------------
margin:0 auto;
------解决方案--------------------
div定位
<style type= "text/css "> #Layer1 { Z-INDEX: 1; LEFT: 254px; WIDTH: 201px; POSITION: absolute; TOP: 115px; HEIGHT: 110px }
</style>
<div class= "Layer1 ">
------解决方案--------------------
<div id= "xx " width=800px; margin-right: auto; margin-left: auto; >

<div id= "xx " width=800px; margin:0 auto; >

给分

------解决方案--------------------
div 父级元素: text-align:center;(body{text-align:center;}
div :margin:0 auto; (据说firefox要这样)
------解决方案--------------------
style= "width:800px;margin:0 auto; "
------解决方案--------------------
同意这个:
<div style = "left:50%; position :relative ; margin-left:-400px ">
------解决方案--------------------

<style type= "text/css ">
/* <![CDATA[*/
div {
position:absolute;
top:50%;
left:50%;
margin:-100px 0 0 -100px;
width:200px;
height:200px;
border:1px solid red;
}
/*]]> */
</style> </head> <body>
<div> .怎样使一个层垂直居中于浏览器中 </div>
</body> </html>