<!DOCTYPE html>
<html lang="zh-CN">
<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>
*{
margin: 0;
padding: 0;
}
li {
list-style: none;
height: 50px;
line-height: 50px;
text-align: center;
}
a {
text-decoration: none;
color: #fff;
}
.box{
display: flex;
width: 1000px;
height: 500px;
margin: 50px auto;
}
ul {
width: 180px;
padding-top: 50px;
background-color: #111;
}
ul li.active{
background-color: #555;
}
.box .content {
flex: 1;
position: relative;
}
.box .content div {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: none;
}
.box .content div.active{
display: block;
}
</style>
</head>
<body>
<div class="box">
<ul>
<li class="active"><a href="javascript:">第1行导航</a></li>
<li><a href="javascript:">第2行导航</a></li>
<li><a href="javascript:">第3行导航</a></li>
<li><a href="javascript:">第4行导航</a></li>
<li><a href="javascript:">第5行导航</a></li>
</ul>
<div class="content">
<div style="background-color: #aff;" class="active"></div>
<div style="background-color: #faf;"></div>
<div style="background-color: #ffa;"></div>
<div style="background-color: #faa;"></div>
<div style="background-color: #aaf;"></div>
</div>
</div>
<script>
let liList = document.querySelectorAll('li')
let divList = document.querySelectorAll('.content div')
for(let i = 0;i<liList.length;i++){
liList[i].onclick=function(){
document.querySelector('li.active').classList.remove('active')
document.querySelector('div.active').classList.remove('active')
liList[i].classList.add('active')
divList[i].classList.add('active')
}
}
</script>
</body>
</html>