对于div的居中 ,如果是有固定宽高的,可以加margin:auto;水平垂直居中,但如果是不固定宽高,又想让div居中的话,这种方式都可能不奏效,达不到想要的效果。

有两种方法:1、加display:inline;变成内联元素,可以给父级加text-align:center

2. 

.inwrap {
        float: left;
        position: relative;
        left: 50%;    
    }
    .page {
        float: left;
        position: relative;
        left: -50%;
    }
<div class="wrap clearfix">
        <div class="inwrap">
            <div class="page">
                这是内容
            </div>
        </div>
    </div>

 

相关文章:

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