如何讓img設置成爲div中的背景圖片

<!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=utf-8" />
 <link rel="stylesheet" href="default.css" type="text/css" />
<script src=".jquery.js" type="text/javascript"></script>
 <script type="text/javascript">

 </script>
</head>
<body>
 <div class="div0">
	<div class="div1">
		<img src="hello.jpg"/>
		<div class="div2">
			<table class="table1">
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
				<tr>
					<td>11111111111111111111111111</td><td>22222222222222222222222</td>
				</tr>
			</table>	
		</div>
	</div>
</div>
</body>
</html>
.div0{
	margin:0 auto;
	height:360px;
	width:360px;
	overflow:hidden;
	border:2px solid Black;
}

.div1{
	position:relative;
	margin:0 auto;
	width:350px;
	height:300px;
	border:1px solid Blue;
}

.div2{
	padding-left:10px;
	overflow:auto;
	height:280px;
	border:1px solid Black;
}


.table1 tr td{
	border:1px solid Black;
}
img{
position:absolute;
  left:0px;
  top:10px;
  z-index:-1;
width:100%!important; 
height:96%!important; 
width:expression(this.width > 150 ? "150px" : this.width)!important;}
}

注:在設置absolute時,父類必須是:relative
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章