在绝对定位中进行水平垂直居中的两种方法
1.这种方法最常用,适合固定长宽的块级元素<pre name="code" class="css" style="font-size: 18px; font-weight: bold;">{
width:300px;
height:200px;
left:50%;
top:50%;
margin-top:-100px;
margin-left:-150px;
}
2.这种方法应用更加广泛,适合固定以及不定长宽的块级元素
<pre name="code" class="css" style="font-size: 18px; font-weight: bold;">{
width:300px;
height:200px;
left:50%;
top:50%;
margin-top:-100px;
margin-left:-150px;
}
{
max-width:300px;
max-height:200px;
left:0;
top:0;
right:0;
bottom:0;
margin:auto;
}