后台管理系统布局
一、顶部固定,左侧导航栏,右侧main区域
左侧导航栏内容超出,出现滚动条,右侧内容,背景色全屏铺满,内容超出,出现滚动条。
a.左侧可以绝对定位,main区域通过margin-left来隔开,高度通过vh单位来实现。
b.侧边栏可以浮动
c.侧边栏可以固定定位
代码参考:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
body{
height: 100%;
}
#app {
height: 100%;
}
.header {
height: 60px;
background-color: #2b83f9;
}
.sidebar {
// position: fixed;
// width: 200px;
// background-color: #ccc;
// top: 60px;
// left: 0;
// bottom: 0;
// overflow-y: auto;
position: absolute;
width: 200px;
background-color: #ccc;
top: 60px;
bottom: 0;
overflow-y: auto;
}
.main {
margin-left: 200px;
background-color: #888;
height: calc(100vh - 60px);
overflow: auto;
}
</style>
</head>
<body>
<div id="app">
<div class="header">Header</div>
<div class="sidebar">
Sidebar
<p>1111</p>
<p>1111</p>
<p>1111</p>
<p>1111</p>
<p>1111</p>
<p>1111</p>
<p>1111</p>
<p>1111</p>
<p>1111</p>
<p>1111</p>
<p>1111</p>
<p>1111</p>
</div>
<div class="main">
App Main
</div>
</div>
</body>
</html>