顶部固定居中

 <div class="w960 fixed">
        我是固定的
    </div>

.w960{
width: 960px;
margin:0 auto;
}
.fixed{
position: absolute;
top:0;
left: 0;
right: 0;
height: 90px;
background: #ececec;
}

垂直居中

<div id="box">
        <div class="son">ssss</div>
    </div>

#box {
    width: 600px;
    height: 500px;
    position: relative;
    border: 1px solid #f00;
}
.son {
    width: 100px;
    height: 100px;
    border: 1px solid #ecc;
    position: absolute;
    left: 50%;
    margin-left: -50px;
    top: 50%;
    margin-top: -50px;
}

 

相关文章:

  • 2021-12-28
  • 2021-12-22
  • 2021-11-23
  • 2022-12-23
  • 2021-08-31
  • 2021-07-20
  • 2022-02-06
猜你喜欢
  • 2021-05-17
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案