代码示例

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>图片垂直居中</title>
    <style type="text/css">
    div {
        position: absolute;
        top: 50%;
        left: 50%;
        -webkit-transform: translate(-50%, -50%);
        -moz-transform: translate(-50%, -50%);
        -ms-transform: translate(-50%, -50%);
        -o-transform: translate(-50%, -50%);
        transform: translate(-50%, -50%);
    }
    </style>
</head>
<body>
    <div><img src="图片地址"/></div>
</body>
</html>