HTML中使背景图片自适应浏览器大小

 

1、图片不够大,又background属性不能拉伸图片; 2、只能用个div,把其z-index值设为负,并使这个div大小为整个body大小,在div里用<img> 3、body的background属性去掉,要不然会被遮住

例子:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>hello world</title>
</head>
<body>

<div style="position:absolute; 100%; height:100%; z-index:-1; left:0; top:0;">
<img src="th.jpg" height="100%" width="100%" style="left:0; top:0;">
</div>
</body>
</html>

原文地址:https://www.cnblogs.com/steven-snow/p/7569076.html