DIV 垂直 垂直水平 居中

DIV 垂直 居中
讓div居中對齊 使用margin-left:auto;margin-right:auto; 可讓你的div居中對齊。  .style{margin-left:auto;margin-right:auto;}  縮寫形式爲:  .style{margin:0 auto;}  數字0 表示上下邊距是0。能夠按照須要設置成不一樣的值。 
<style type="text/css">
 .align-center{
    margin:0 auto; /* 居中 這個是必須的,,其它的屬性非必須 */
    width:500px; /* 給個寬度 頂到瀏覽器的兩邊就看不出居中效果了 */
    background:red; /* 背景色 */
     /* 文字等內容居中 text-align:center;*/
}
</style>
 
@Html.Partial("_PartialMenuImg", "../../Images/Sys/test.jpg")
 
<div class="align-center"></div>
 
DIV 垂直水平 居中
1,關於居中使用css爲:position:fixed;left:50%;top:50%;margin-left:width/2;margin-top:height/2;  對於ie6,只能把position:改爲absolute; 
 
<!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" lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>水平垂直居中div演示效果</title>
<style type="text/css">
.align-center{
position:fixed;left:50%;top:50%;margin-left:width/2;margin-top:height/2;
}
</style>
</head>
<body>
<div class="align-center">水平垂直居中div演示效果</div>
</body>
</html>