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

边栏推荐
- Sqlserver gets the data of numbers, Chinese and characters in the string
- Windbg调试工具介绍
- 1-21 jsonp interface
- 微服务链路风险分析
- Some problems when SSH default port is not 22
- PyTorch量化感知训练(QAT)步骤
- Stinky tofu made by Grandma
- Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
- Jupyterbook clear console output
- Sqlserver string type converted to decimal or integer type
猜你喜欢

Open the jupyter notebook/lab and FAQ & settings on the remote server with the local browser

Error filesystemexception: /data/nodes/0/indices/gttxk-hntgkhacm-8n60jw/1/index/ es_ temp_ File: structure needs cleaning

JD and Tencent renewed the three-year strategic cooperation agreement; The starting salary rose to 260000 yuan, and Samsung sk of South Korea scrambled for a raise to retain semiconductor talents; Fir

Uniapp life cycle / route jump

机器学习中如何使用数据集?

PyTorch量化实践(1)

Vite2 is compatible with lower versions of chrome (such as Sogou 80). Some grammars requiring higher versions are processed through polyfills
![Flip the linked list ii[three ways to flip the linked list +dummyhead/ head insertion / tail insertion]](/img/a8/6472e2051a295f5e42a88d64199517.png)
Flip the linked list ii[three ways to flip the linked list +dummyhead/ head insertion / tail insertion]

Neurotransmetteurs excitateurs - glutamate et santé cérébrale

Go Web 编程入门: 一探优秀测试库 GoConvey
随机推荐
FreeRTOS record (IX. an example of a bare metal project transferring to FreeRTOS)
Document Layout Analysis: A Comprehensive Survey 2019论文学习总结
Uniapp life cycle / route jump
Is it safe to open an account for stock trading on mobile phones?
A comprehensive understanding of gout: symptoms, risk factors, pathogenesis and management
ML&DL:機器學習和深度學習中超參數優化的簡介、評估指標、過擬合現象、常用的調參優化方法之詳細攻略
Some problems when SSH default port is not 22
Ml & DL: Introduction à l’optimisation des hyperparamètres, indice d’évaluation, phénomène de surajustement et introduction détaillée aux méthodes d’optimisation des paramètres couramment utilisées da
Arcmap|assign values to different categories of IDS with the field calculator
1-20 预检请求
Summary of errors reported when using YML file to migrate CONDA environment
Best wishes for Lao Wu's party
吴恩达的机器学习适合入门吗?
Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022
【回溯】全排列 leetcode46
1-13 express listens to get and post requests & processes requests
Introduce an online platform for multi omics integration and network visual analysis
1-10 根据不同的url响应客户端的内容
[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)
周少剑,很少见