效果:
代码:
<!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" />
<style>
*{ margin:0; padding:0 }
a{ text-decoration: none; }
img{
border: none;
}
.background{
height: 200px;
position: absolute;
width: 100%;
background: url(一张width大于900px,height大于100px的banner图) 50% 0 no-repeat;
z-index: -1;
left:0;
right:0;
}
.back{
height: 100px;
position: relative;
width: 900px;
margin: 0 auto;
}
.back .content{
bottom: 20px;
font-size: 24px;
color: orange;
position: absolute;
right: 20px;
}
.main{
margin:0 auto;
width:900px;
background: gray;
height: 900px;
}
</style>
</head>
<body>
<div class="background">
</div>
<div class="back">
<a href="" target="_blank"><div class="content">
返回首页
</div>
</a>
</div>
<div class="main">文章内容</div>
<body>
</html>
知识点:
百分比的计算方法:
x=(容器宽度-背景图片宽度)*百分数
y=(容器高度-背景图片高度)*百分数