当前位置:网站首页>Web APIs comprehensive case -tab column switching - dark horse programmer
Web APIs comprehensive case -tab column switching - dark horse programmer
2022-06-30 22:03:00 【Dark horse programmer official】
Have learned the above contents , Today, let's make a comprehensive case :Tab Bar Toggle

analysis :
html Code :
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title></title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
ul {
list-style: none;
}
.wrapper {
width: 1000px;
height: 475px;
margin: 0 auto;
margin-top: 100px;
}
.tab {
border: 1px solid #ddd;
border-bottom: 0;
height: 36px;
width: 320px;
}
.tab li {
position: relative;
float: left;
width: 80px;
height: 34px;
line-height: 34px;
text-align: center;
cursor: pointer;
border-top: 4px solid #fff;
}
.tab span {
position: absolute;
right: 0;
top: 10px;
background: #ddd;
width: 1px;
height: 14px;
overflow: hidden;
}
.products {
width: 1002px;
border: 1px solid #ddd;
height: 476px;
}
.products .main {
float: left;
display: none;
}
.products .main.active {
display: block;
}
.tab li.active {
border-color: red;
border-bottom: 0;
}
</style>
</head>
<body>
<div class="wrapper">
<ul class="tab">
<li class="tab-item active"> Big international card <span>◆</span></li>
<li class="tab-item"> National makeup brand <span>◆</span></li>
<li class="tab-item"> Cleaning products <span>◆</span></li>
<li class="tab-item"> Men's Boutique </li>
</ul>
<div class="products">
<div class="main active">
<a href="###"><img src="imgs/guojidapai.jpg" alt="" /></a>
</div>
<div class="main">
<a href="###"><img src="imgs/guozhuangmingpin.jpg" alt="" /></a>
</div>
<div class="main">
<a href="###"><img src="imgs/qingjieyongpin.jpg" alt="" /></a>
</div>
<div class="main">
<a href="###"><img src="imgs/nanshijingpin.jpg" alt="" /></a>
</div>
</div>
</div>
<script>
// 0. Get elements
// Get all the little li
let lis = document.querySelectorAll('.tab .tab-item')
let divs = document.querySelectorAll('.products .main')
// 1. Head tab Column switching module
// 1.1 First give 4 Small li Add click event
for (let i = 0; i < lis.length; i++) {
lis[i].addEventListener('click', function () {
// console.log(11)
// Find the old active class , Remove
document.querySelector('.tab .active').classList.remove('active')
// Add the current element
this.classList.add('active')
// 2. Show hidden modules at the bottom Be sure to write in the click event
document.querySelector('.products .active').classList.remove('active')
// div The one corresponding to the serial number plus active
divs[i].classList.add('active')
})
}
</script>
</body>
</html> Material pictures :



How are you doing ? The comments can tell me ~~
Dark horse front-end column has a lot of dry goods , Focus on relearning , It's convenient ~
2022 Front end learning roadmap : Course 、 Source code 、 note , Technology stack In addition, the circuit diagram is updated in real time ! Friends who need after-school materials , You can tell me directly .

边栏推荐
- 1-11 create online file service
- 《Dynamic Routing Between Capsules》论文学习总结
- Develop technology - get time 10 minutes ago
- 1-21 JSONP接口
- 1-10 respond to client content according to different URLs
- Excitatory neurotransmitter glutamate and brain health
- Notes [introduction to JUC package and future]
- Qsort function and Simulation Implementation of qsort function
- [untitled] first time to participate in CSDN activities
- Is it safe to open an account for stock trading on mobile phones?
猜你喜欢

Excitatory neurotransmitter glutamate and brain health

Stinky tofu made by Grandma

Pytorch quantitative practice (2)

Anaconda下安装Jupyter notebook

阿婆做的臭豆腐
Notes [introduction to JUC package and future]

Best wishes for Lao Wu's party

Introduce an online platform for multi omics integration and network visual analysis

Which direction should college students choose to find jobs after graduation?

Alibaba Kube eventer MySQL sink simple usage record
随机推荐
1-3 使用SQL管理数据库
在启牛开的股票账户安全吗?如何申请低佣金的股票账户?
Pytorch quantitative practice (2)
牛逼|珍藏多年的工具让我实现了带薪摸鱼自由
Stimulate new kinetic energy to develop digital economy in multiple places
vncserver: Failed command ‘/etc/X11/Xvnc-session‘: 256!
Analyse des risques liés aux liaisons de microservices
PyTorch量化实践(1)
机器学习适合女生学吗?
Best wishes for Lao Wu's party
Uniapp life cycle / route jump
Notes [introduction to JUC package and future]
Zhoushaojian, rare
机器学习中如何使用数据集?
Pytorch quantitative perception training (qat) steps
1-10 respond to client content according to different URLs
Usbcan analyzer's supporting can and canfd comprehensive test software lkmaster software solves engineers' can bus test problems
SQL server extracts pure numbers from strings
盘点华为云GaussDB(for Redis)六大秒级能力
Deployment and use of Nacos