图片在窗口中上下左右垂直居中代码

发布时间:2020-01-20 15:50:24   分类:网页代码0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<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>
<title>图片在浏览器窗口中上下左右垂直居中代码</title>
</head>

<body>
<div><img src="http://img.lanrentuku.com/img/allimg/1609/5-160Z1192U5-50.jpg" alt="" /></div>
</body>
</html>
QQ咨询