<div >11111111111111111111</div>
</div>

 

1.相对定位:

 #box{position:relative; left:50%; float:left;}


 #inner{position:relative; left:-50%;}

需考虑浮动带来的问题

2.利用diplay:table来解决:

#box{ display:table;margin:0 auto}
不支持ie6,ie7

3.CSS3 flex-box 居中方案

#box{position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: -webkit-box;  -webkit-box-align: center;-webkit-box-pack: center;}

#inner{-webkit-box-flex: 0;background: #CCC;}

相关文章:

  • 2022-12-23
  • 2021-10-27
  • 2021-09-09
  • 2021-11-21
  • 2022-12-23
  • 2022-01-30
  • 2021-12-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
相关资源
相似解决方案