大背景图在低分辨率浏览器中始终显示中间部分

来源:互联网 发布:开网店需要什么软件 编辑:程序博客网 时间:2024/04/19 21:26
<!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" />
<title>无标题文档</title>
<style>
div,body,html {
margin:0;
width:100%;
height:100%
}
.main{
background:url(http://news.mydrivers.com/img/20080628/07552404.jpg) no-repeat; 
background-position:top center;

</style> 
</head> 
<body> 
<div class="main"></div> 
</body> 
</html>




还可以用下面方法实现:
css:
.div{ position:relative; width:1000px;}
.div2{ position:absolute; left:-593px; top:0px;}
html:
<div class="div">
<div class="div2">图片地址</div>
</div>
0 0