设置img水平垂直居中

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
       <style type="text/css">
           img{
            position: absolute;
            top:50%; 
            left:50%;
            transform: translate(-50%,-50%);
        }
       </style>
</head>
<body>
    <form id="form1" runat="server">
            <img alt="" src="/images/qhfgs@2x.png"  />
    </form>
</body>
</html>

单纯水平居中可以使用

margin:0 auto;100px

原文地址:https://www.cnblogs.com/zhaogaojian/p/13609376.html