如何使能DIV垂直和水平居中
<style type="text/css">
.center-middle1 {
position:absolute;
background-color: #e2e2e2;
width: 100%;
height: 300px;
top:50%;
margin-top: -150px; }
.center-middle2 {
position:absolute;
background-color: #e2e2e2;
width: 300px;
height: 200px;
left:50%;
top:50%;
margin-left: -150px;
margin-top: -100px; }
</style>
<style type="text/css"> <!-- .center-middle1 {position:absolute; background-color:#e2e2e2; width:100%; height:300px; top:50%; margin-top:-150px} .center-middle2 {position:absolute; background-color:#e2e2e2; width:300px; height:200px; left:50%; top:50%; margin-left:-150px; margin-top:-100px} --> </style>
用例:
<div class="enter-middle2">
如何使能DIV垂直和水平居中
</div>