让img居中的方法

html模板:

<div class="container">
        <img src="img/1.png" alt="" style=" 100px;height: 100px;">
    </div>
View Code

1.水平垂直居中

  A.转化为表格单元格的形式

 .container{
            display: table-cell;
            width: 600px;
            height: 500px;
            vertical-align: middle;
            text-align: center;
            border: 1px solid black;
        }
View Code
原文地址:https://www.cnblogs.com/QIQIZAIXIAN/p/6932123.html