上图
上代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div class="w">
<div class="top">
<div class="ssk">选项1</div>
<div >选项2</div>
<div >选项3</div>
<div >选项4</div>
</div>
<div class="fot">
<div class="ccg">盒子1</div>
<div>盒子2</div>
<div>盒子3</div>
<div>盒子4</div>
</div></div>
<script>
var btn=document.getElementsByClassName("top")[0].getElementsByTagName("div")
var box=document.getElementsByClassName("fot")[0].getElementsByTagName("div")
for(var i=0;i<btn.length;i++){
btn[i].index=i
btn[i].οnclick=function(){
for(var y=0;y<btn.length;y++){
btn[y].className=""
box[y].className=""
}
this.className="ssk"
box[this.index].className="ccg"
}
}
</script>
<style>
.w .fot div{
height: 499px;
width: 800px;
text-align: center;
line-height: 499px;
background-color: black;
color: aqua;
font-size: 50px;
display: none;
}
.w .fot .ccg{
display: block;
}
.w{
width: 800px;
height: 800px;
border:1px solid red ;
margin: 100px auto;
}
.w .top {
display: flex;
border-bottom: 1px solid green;
}
.w .top .ssk{
background-color: red;
}
.w .top div{
width: 200px;
height: 300px;
text-align: center;
font-weight: 900;
background-color: black;
color: white;
font-size: 30px;
line-height: 300px;
}
.w .top div:hover{
background-color: red;
cursor: pointer;
}
</style>
</body>
</html>
复制粘贴就能用