图片垂直居中在中间

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>图片垂直居中在中间</title>
</head>
<style type="text/css">
.war {
    width:100%;
    height:100%;
    overflow:hidden;
    display:-webkit-box;
    -webkit-box-align:center;
    -webkit-box-pack:center;
    display:-ms-flexbox;
    -ms-flex-pack:center;
    -ms-flex-align:center;
    position:absolute;
    position:fixed;
    top:0;
    right:0;
    left:0;
    bottom:0;
}
.war img {
    max-height:100%;
    max-width:100%;
}
</style>

<body>
<div class="war"> <img src="image/2.jpg"> </div>
</body>
</html>

 

posted @ 2015-07-22 17:17  328201736  阅读(227)  评论(0编辑  收藏  举报