目录
希望能够帮到你哦~
1.主要页面
2.相关部分的介绍
2.1 首先整体的构思
这里用到的是CSS盒子的思想 首先我们需要用一个大盒子作为主体页面 接着放三个小盒子 来完成页面的布局
2.2 相关代码的解释
</head>
<body>
<div class="box">
<div class="header">
<ul>
<li><a href="#" onclick="showContent('main')">首页</a></li>
<li><a href="#" onclick="showContent('user')">用户管理</a></li>
<li><a href="#" onclick="showContent('artical')">文章管理</a></li>
</ul>
</div>
<div class="article">
<h1 class="title">欢迎来到后台管理系统</h1>
</div>
<div class="content" id="content">
<p class="title2">工作区域</p>
</div>
第一个盒子是header 也就是导航栏部分 这里有三个用链接a标签做成的按钮 用以实现页面的跳转 第二个盒子是artical 也就是最上面的部分 第三个盒子是content,也就是主要内容的呈现 当用户点击时 实现页面的跳转
然后我们再来看看css的相关代码
<style type="text/css">
/* 用以消除其他标签自带的margin和padding 防止盒子被撑大 */
*{
margin: 0;
padding: 0;
}
/* 主体盒子的相关设定
1.margin 设置成居中的样式 0表示上下无间距 左右居中
2.box-sizing 保证盒子的原有尺寸
*/
.box{
background-color: rgb(243,246,248);
margin: 0 auto;
width: 1080px;
height: 1080px;
box-sizing: border-box;
}
/* 将ul标签自带的序号点消除 */
ul{
list-style: none;
}
/* 将文字居中 */
.header li{
padding: 15px;
text-align: center;
}
/* 消除下划线 */
a{
text-decoration: none;
color:rgb(98,95,92)
}
/* 利用浮动的思想 将该盒子左浮动 位置固定在左边*/
.header{
float: left;
background-color: rgb(243,246,248);
width: 160px;
height: 1080px;
position: fixed;
}
.article{
float: right;
width: 910px;
height: 71px;
background-color: rgb(255,255,255);
margin-left:8px ;
border-left:8px solid rgb(0,116,114) ;
box-sizing: border-box;
}
.title{
line-height: 71px;
margin-left: 8px;
}
/* 当光标停留在标签a上时 文字颜色变成红色 */
a:hover{
color: red;
}
.content{
float: right;
width: 910px;
height: 1001px;
background-color: rgb(255,255,255);
margin-top: 8px;
}
.title2{
text-align: center;
margin: 8px;
}
.title3{
margin: 8px;
}
</style>
3.源代码如下:
<!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>Document</title>
<style type="text/css">
/* 用以消除其他标签自带的margin和padding 防止盒子被撑大 */
*{
margin: 0;
padding: 0;
}
/* 主体盒子的相关设定
1.margin 设置成居中的样式 0表示上下无间距 左右居中
2.box-sizing 保证盒子的原有尺寸
*/
.box{
background-color: rgb(243,246,248);
margin: 0 auto;
width: 1080px;
height: 1080px;
box-sizing: border-box;
}
/* 将ul标签自带的序号点消除 */
ul{
list-style: none;
}
/* 将文字居中 */
.header li{
padding: 15px;
text-align: center;
}
/* 消除下划线 */
a{
text-decoration: none;
color:rgb(98,95,92)
}
/* 利用浮动的思想 将该盒子左浮动 位置固定在左边*/
.header{
float: left;
background-color: rgb(243,246,248);
width: 160px;
height: 1080px;
position: fixed;
}
.article{
float: right;
width: 910px;
height: 71px;
background-color: rgb(255,255,255);
margin-left:8px ;
border-left:8px solid rgb(0,116,114) ;
box-sizing: border-box;
}
.title{
line-height: 71px;
margin-left: 8px;
}
/* 当光标停留在标签a上时 文字颜色变成红色 */
a:hover{
color: red;
}
.content{
float: right;
width: 910px;
height: 1001px;
background-color: rgb(255,255,255);
margin-top: 8px;
}
.title2{
text-align: center;
margin: 8px;
}
.title3{
margin: 8px;
}
</style>
</head>
<body>
<div class="box">
<div class="header">
<ul>
<!-- onclick 绑定相应的事件 -->
<li><a href="#" onclick="showContent('main')">首页</a></li>
<li><a href="#" onclick="showContent('user')">用户管理</a></li>
<li><a href="#" onclick="showContent('artical')">文章管理</a></li>
</ul>
</div>
<div class="article">
<h1 class="title">欢迎来到后台管理系统</h1>
</div>
<div class="content" id="content">
<p class="title2">工作区域</p>
</div>
<!-- 利用脚本语言实现页面的跳转 -->
<script>
function showContent(id) {
var content = document.getElementById('content');
if (id === 'main') {
content.innerHTML = '<h1 class="title3">Welcome to my website!</h1><p class="title3">This is the home page.</p>';
} else if (id === 'user') {
content.innerHTML = '<h1 class="title3">About Us</h1><p class="title3">Learn more about our company.</p>';
} else if (id === 'artical') {
content.innerHTML = '<h1 class="title3">Our Services</h1><p class="title3">Discover what we can do for you.</p>';
}
}
</script>
</div>
</body>
</html>
关于相关页面的跳转 也可以用iframe标签 就不多赘述啦~ 再见