1. table-cell方法

/*父元素*/
{display:table-cell;vertical-align:middle;text-align:center}
/*子元素*/
{vertical-align: middle;display:inline-block}

2. transform方法

/*父元素*/
{position:relative}
/*子元素*/
{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}

3. flex方法

/*父元素*/
{display:flex;justify-content:center;align-items:center;}

 

相关文章:

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