父(元素)标签中的子(元素)标签水平垂直居中

<div class=”box”>

<img class=”img”/>

</div>

.box{ position: relative;}

.img{  width: 100%;

      position: absolute;

      top: 50%;

      left: 50%;

      transform: translate(-50%, -50%);}

猜你喜欢

转载自www.cnblogs.com/zjboke/p/11933283.html