iframe简单后台架构
实例代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>简单后台架构</title>
<style>
body {
height: 100vh;
width: 100vw;
display: grid;
grid-template-columns: 10em 1fr;
grid-template-rows: 6em 1fr;
margin: 0;
}
body .header {
grid-column-end: span 2;
border-bottom: 1px solid currentColor;
background-color: #efe;
padding: 2em;
display: flex;
align-items: center;
}
body .header div {
margin-left: 500px;
}
body .nav {
background-color: #efc;
margin: 0;
padding-top: 1em;
list-style: none;
}
body iframe {
width: calc(50vw - 5em);
height: calc(50vh - 3em);
border-left: 1px solid currentColor;
}
</style>
</head>
<body>
<!-- 页面顶端 -->
<div class="header">
<h1>后台管理</h1>
<div>
<span>admin</span>
<a href="">退出</a>
</div>
</div>
<!-- 左侧导航 -->
<ul class="nav">
<li><a href="" demo1.html="" target="content">菜单项1</a></li>
<li><a href="" demo2.html="" target="content">菜单项2</a></li>
<li><a href="" demo3.html="" target="content">菜单项3</a></li>
<li><a href="" demo4.html="" target="content">菜单项4</a></li>
</ul>
<!-- 右侧内容 -->
<iframe src="" frameborder="1" name="content" style="border-color:aquamarine;"></iframe>
</body>
</html>
运行代码效果如下: