Ruth92

CSS 实现:文字水平垂直居中

☊ 【实现要求】:

demo1

<div class="demo1">
    标题1111
</div>

√ 【实现】:

方案一:普通布局

.demo1 {
    text-align: center;	//水平居中
    line-height: $height; //垂直居中
}

方案二flex 布局

.demo1 {
    display: flex;
    display: -webkit-flex;
    justify-content: center; //水平居中
    align-items: center; //垂直居中
}

方案三box 布局(2009年语法,flex 的前身)

.demo1 {
    display: box;
    display: -webkit-box;
    -webkit-box-pack:center; //水平居中
    -webkit-box-align:center; //垂直居中
}

分类:

技术点:

相关文章:

  • 2021-09-13
  • 2021-11-19
  • 2021-12-01
  • 2021-09-13
  • 2022-01-07
  • 2021-06-01
  • 2021-12-03
  • 2021-12-15
猜你喜欢
  • 2021-08-31
  • 2021-10-10
  • 2022-01-03
  • 2022-01-30
  • 2022-02-11
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案