1 Star 1 Fork 0

柠檬/studentSystem

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo.html 2.11 KB
一键复制 编辑 原始数据 按行查看 历史
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html{
font-size: 16px;
}
body,div,p,input{
margin: 0;
padding: 0;
border: 0;
}
/* reset CSS end */
.tabbar{
margin-left: 180px;
}
.btn{
float: left;
border: 1px solid #ccc;
border-top-left-radius:6px ;
border-top-right-radius:6px ;
padding: 5px 1rem;
cursor: pointer;
background-color:orange;
color: #fff;
}
.clear{
clear: both;
}
#content{
width: 32rem;
height: 20rem;
padding: 20px;
border: 1px solid #ccc;
background: linear-gradient(to bottom,#56a5f1,#fff);
position: relative;
top: -1px;
z-index: -1;
}
.checked{
background-color: #56a5f1;
border-bottom: 1px solid transparent;
}
</style>
</head>
<body>
<div class="tabbar">
<div class="btn checked">首页</div>
<div class="btn ">音乐</div>
<div class="btn ">新闻</div>
<div class="clear"></div>
<div id="content"></div>
</div>
<script>
let homeContent = `这是首页的内容`;
let musicContent = `这是音乐的内容`;
let newsContent = `这是新闻的内容`;
let textContent = [];
textContent.push(homeContent,musicContent,newsContent);
//显示默认内容
content.innerHTML = textContent[0];
//点击切换
let btn = document.querySelectorAll('.btn');
for(let i = 0 ;i<btn.length;i++){
let obj = btn[i];
obj.btnIndex = i;
obj.onclick = function(e){
console.log(e.target.btnIndex)
content.innerHTML = textContent[e.target.btnIndex];
}
}
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/yan_jun_feng/studentSystem.git
git@gitee.com:yan_jun_feng/studentSystem.git
yan_jun_feng
studentSystem
studentSystem
master

搜索帮助