方法一:利用行高(line-height)定位

方法二:利用绝对定位

元素的宽度/2 = 负左边距
元素的高度/2 = 负上边距

在这个例子中,我们就是这么计算的
.vert {
        width: 580px;
        height: 190px;
        position: absolute;
        top: 50%;
        left: 50%;

        margin: -95px 0 0 -290px;
}
参考:http://www.cssxuexi.cn/forum.php?mod=viewthread&tid=337&extra=page%3D1

相关文章:

  • 2021-08-23
  • 2021-10-13
猜你喜欢
  • 2022-01-08
  • 2021-12-22
  • 2021-06-17
  • 2021-09-30
  • 2021-11-25
相关资源
相似解决方案