html, body {
width: 100%;
height: 100%;
}
- 如果使用
vue-cli
构建的话,请在public
下的index
页面添加
#app {
width: 100%;
height: 100%;
}
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Title</title>
<style>
html, body {
width: 100%;
height: 100%;
}
div {
width: 100%;
height: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
}
header {
height: 60px;
line-height: 60px;
text-align: center;
background-color: lightblue;
}
main {
flex: 1;
width: 100%;
height: 100%;
padding: 1px;
overflow-y: auto;
}
footer {
height: 60px;
line-height: 60px;
text-align: center;
background-color: orange;
}
</style>
</head>
<body>
<div>
<header>ff</header>
<main>
<p>hh</p>
<p>hh</p>
<p>hh</p>
</main>
<footer>hh</footer>
</div>
</body>
</html>
- 结果
