盒子模型上下左右居中方法总结

1.采用负边距和position结合方式

<html>
<head></head>
<body>
<style type="text/css">
.big{
position:relative;background:#eee;
100%;height:100%;
}
.small{
position:absolute;top:50%;left:50%;
200px;height:200px;border:1px solid red;
margin:-100px 0 0 -100px;background:#fff;
}
</style>
<div class="big">
  <div class="small">盒子居中</div>
</div>
</boyd>
</html>
原文地址:https://www.cnblogs.com/bigdesign/p/3992549.html