源码:
<!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>
* {
margin: 0;
padding: 0;
list-style: none;
}
.app {
width: 400px;
height: 400px;
border: 1px solid gray;
margin: 0 auto;
}
.title {
width: 100%;
height: 40px;
font-size: 0;
}
li {
height: 37px;
display: inline-block;
background-color: #eee;
font-size: 16px;
text-align: center;
line-height: 37px;
box-sizing: border-box;
border: 1px solid rgb(199, 198, 198);
vertical-align: bottom;
}
li:first-child {
width: 100px;
}
li:nth-child(2) {
width: 100px;
}
li:last-child {
width: 200px;
}
.choose {
background-color: #fff;
/* box-sizing: border-box; */
border: none;
border-top: 3px solid gold;
}
.content {
width: 100%;
height: 350px;
text-align: center;
line-height: 350px;
background-color: #fff;
}
.box {
display: none;
}
.active {
display: block;
}
</style>
</head>
<body>
<div class="app">
<ul class="title">
<li>体育</li>
<li class="choose">NBA</li>
<li>体育视频</li>
</ul>
<div class="content">
<div class="box">体育</div>
<div class="box active">NBA</div>
<div class="box">体育视频</div>
</div>
</div>
<script src="/通用资源/jquery.js"></script>
<script>
var list = $('li');
var box = $('.box');
list.click(function() {
$(this).addClass('choose').siblings().removeClass('choose');
box.eq($(this).index()).addClass('active').siblings().removeClass('active');
});
</script>
</body>
</html>
效果图: