<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style type="text/css">
/*让body 和html 占满浏览器*/
body,html {
margin: 0;
padding: 0;
height:100%;
}
/*让main占满浏览器*/
#main {
position: relative;
min-height:100%;
background:#ccc;
}
/*主体内容的padding-bottom要等于页脚的高度*/
#content {
padding-bottom: 100px;
}
/*页脚要绝对定位,并bottom为0*/
#footer {
position: absolute;
bottom: 0;
height: 100px;
width: 100%;
background:gray;
}
</style>
</head>
<body>
<div id="main">
<div id="content">
这里是网页的主体内容
</script>
</div>
<div id="footer">
Footer
</div>
</div>
</body>
</html>