The text and pictures in the div are horizontally centered

<div  style="display: flex;align-items: center;">

    <img  style="display:table-cell" />

    <span  style="display:table-cell"></span>

</div>

0. The text is displayed on the right side of the div

text-align: right;

1. Align both ends of two lines of text

text-align: justify

2. Align the image in the center of the div

<div>
  <img src="">
</div>


div{
  width:200px;
  height:200px;
  border:1pxsolid#ccc;
  position:relative;//父元素设置绝对定位
}

img{
  position:absolute;//相对定位
  width:80px;
  height:50px;
  top:0;
  left:0;
  right:0;
  bottom:0;
  margin:auto;//使其垂直居中
}

Guess you like

Origin blog.csdn.net/weixin_41955606/article/details/132523879