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

<html>
<head></head>
<body>
<style type="text/css">
.big{
position:relative;background:#eee;
width:100%;height:100%;
}
.small{
position:absolute;top:50%;left:50%;
width: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>

 

相关文章:

  • 2021-11-29
  • 2022-01-13
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-10-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-29
  • 2022-01-18
  • 2022-12-23
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案