当前位置:网站首页>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 .

边栏推荐
- The programmer's girlfriend gave me a fatigue driving test
- Deployment and use of Nacos
- About, Qianxin detects code vulnerabilities and XSS series solves them
- Development techniques - import files using easyexcel (simple example)
- 1-17 express中间件
- 1-15 nodemon
- ML&DL:机器学习和深度学习中超参数优化的简介、评估指标、过拟合现象、常用的调参优化方法之详细攻略
- 【MySQL入门】第一话 · 初入“数据库”大陆
- Niubi | the tools I have treasured for many years have made me free to fish with pay
- Microservice link risk analysis
猜你喜欢

1. Summary of wechat applet page Jump methods; 2. the navigateto stack does not jump to the tenth floor

从PG15 XID64再次跳票说起

阿婆做的臭豆腐

Pytorch quantitative practice (1)

Usbcan analyzer's supporting can and canfd comprehensive test software lkmaster software solves engineers' can bus test problems

Introduction to go web programming: a probe into the excellent test library gocovey

Development techniques - import files using easyexcel (simple example)

SQL server extracts pure numbers from strings

Troubleshooting the problem of pytorch geometric torch scatter and torch spark installation errors

MFC interface library bcgcontrolbar v33.0 - desktop alarm window, grid control upgrade, etc
随机推荐
A comprehensive understanding of gout: symptoms, risk factors, pathogenesis and management
微服務鏈路風險分析
Turn: win others' follow with practical actions
興奮神經遞質——穀氨酸與大腦健康
[untitled] first time to participate in CSDN activities
How to realize the center progress bar in wechat applet
Jupyter notebook/lab switch CONDA environment
[career planning for Digital IC graduates] Chap.1 overview of IC industry chain and summary of representative enterprises
1-11 create online file service
1-13 express listens to get and post requests & processes requests
Prediction and regression of stacking integrated model
全面认识痛风:症状、风险因素、发病机理及管理
《安富莱嵌入式周报》第271期:2022.06.20--2022.06.26
Interesting plug-ins summary
Is there a shortage? No need to download the free online resources! 2022 favorites must have it!
Modify the name of the launched applet
[backtracking] full arrangement leetcode46
Bloom filter
艾芬医生事件解析
[BSP video tutorial] BSP video tutorial issue 19: AES encryption practice of single chip bootloader, including all open source codes of upper and lower computers (June 26, 2022)