第一种方式设置html、body高度100%,footer相对body定位:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
html {
height: 100%;
}
body {
margin: 0;
padding: 0;
min-height: 100%;
position: relative;
background-color: #ccc;
}
.content {
height: 200px;
/*height: 2000px;*/
}
.footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
background-color: orange;
height: 50px;
line-height: 50px;
}
</style>
</head>
<body>