第1种:将固定不动尺寸的div框相对性对话框水平竖直垂直居中,更改访问器对话框尺寸时,仍然维持水平竖直垂直居中;
<!doctype html>
<html lang="en">
<head>
<title>水平竖直垂直居中</title>
<meta charset="utf⑻">
<style type="text/css">
.out{width: 0px;
height: 0px;
position: absolute;
left: 50%;
top: 50%;
}
.in{height: 300px;
width: 300px;
position: absolute;
left: ⑴50px;
top: ⑴50px;
background-color: #999;
}
</style>
</head>
<body>
<div class="out">
<div class="in"></div>
</div>
</body>
</html>
第2种:让1个自融入尺寸的div相对性访问器对话框水平竖直垂直居中
<!doctype html>
<html lang="en">
<head>
<meta charset="utf⑻">
<title>自融入剧中</title>
<style type="text/css">
.middle{
height: 300px;
width: 300px;
border: 1px solid;
display: table-cell;
text-align: center;
vertical-align: middle;
}
.in{
background-color: red;
height: auto;
width: auto;
min-width: 0px;
min-height: 0px;
display: inline;
}
</style>
</head>
<body>
<div class="middle">
<div class="in">內容自融入水平竖直垂直居中</div>
</div>
</body>
</html>