当前位置:网站首页>Tab bar toggle style
Tab bar toggle style
2022-07-25 06:34:00 【If I become a demon, Buddha, I'm a program maniac】
JS Code
<script>
function tablan(){
let ul=document.querySelector(".nav ul")
let lis=ul.querySelectorAll('.nav ul li');
let div=document.querySelectorAll('.nav .conter div');
// Traverse all of li
for(i=0;i<lis.length;i++){
lis[i].setAttribute("index",i)// For each li catalog index
// to li Bind click event
lis[i].onclick=function(){
// Get the current index
for(j=0;j<lis.length;j++){
// Clear away first li The style of
lis[j].className='';
// hide div
div[j].style.display='none';
}
// When clicking the current li Here it is li add to tab-1 style
this.className='tab-1';
// When the mouse clicks this attribute, it is the current index
let thisIndex=this.getAttribute("index");
// Click on li Current div and li The index is the same div Show
div[thisIndex].style.display="block";
}
}
}
tablan();
</script> <style>
*{
margin: 0px;
padding: 0px;
}
a{
text-decoration: none;
}
.nav{
width:1200px;
margin: 40px auto;
border: 1px solid gray;
position: relative;
}
/* .nav>ul::after{
content: '';
display: block;
clear: both;
} */
.nav>ul{
width: 1200px;
list-style: none;
display: flex;
justify-content: space-around;
}
.nav>ul>li{
width: 200px;
height: 60px;
text-align: center;
line-height: 60px;
background: pink;
/* float: left; */
}
.nav>ul>.tab-1{
background: blue;
}
.nav>ul>li>a{
color: grey;
}
.nav>.conter{
width: 1200px;
height: 800px;
overflow: hidden;
/* border: 1px solid gray; */
position: absolute;
top: 60px;
left: 0px;
}
.nav>.conter>div{
width: 1200px;
height: 800px;
border: 1px solid gray;
box-sizing: border-box;
text-align: center;
font-size: 40px;
line-height: 800px;
}
</style> <div class="nav">
<ul>
<li class="tab-1">
<a href="javascript:;">
News page
</a>
</li>
<li>
<a href="javascript:;">
menu bar
</a>
</li>
<li>
<a href="javascript:;">
information service
</a>
</li>
<li>
<a href="javascript:;">
Information business
</a>
</li>
</ul>
<div class="conter">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
</div>
边栏推荐
- 容器内组播
- 百度希壤首场元宇宙拍卖落槌,陈丹青六幅版画作品全部成交!
- Easy gene chip SEQ analysis method: practical workflow and advanced applications
- 【C语言】指针和数组的深入理解(第一期)
- GIS实战应用案例100篇(十七)-基于DEM制作三维地图
- “蔚来杯“2022牛客暑期多校训练营2 Link with Game Glitch (spfa找正负环)
- 长安链双花交易防范策略
- Evolution of coupon architecture under C2B mode
- Keilc51 usage details (III)
- Bug notes
猜你喜欢

Use abp Zero builds a third-party login module (4): wechat applet development
![[C language] program environment and preprocessing](/img/d6/d59a0d8d286ea9408043d8ad1e1348.png)
[C language] program environment and preprocessing

Addition, deletion, modification and query of DOM elements

node.express中req.body总是undefind解决

【C】程序环境和预处理

It is said that screentogif is a GIF recording artifact, but I don't know that its strength is far from here

JS array = number assignment changes by one, causing the problem of changing the original array

2022 "strong country Cup" preliminary WP (with script and detailed process)
![[sword finger offer] analog implementation ATOI](/img/01/76a3b1fcc6403368a363146d553777.png)
[sword finger offer] analog implementation ATOI

DOM event type
随机推荐
SAP FICO section III BDC and ltmc import S4 financial account
“font/woff“ and “font/woff2“ in file “mime.types“
Detailed explanation of the difference, working principle and basic structure between NMOS and PMOS
Android interview question: why do activities rebuild ViewModel and still exist—— Jetpack series (3)
【transformer】DeiT
“font/woff“ and “font/woff2“ in file “mime.types“
Some common interview questions about IO stream and string
Detailed explanation of arm instruction CMP
[cann training camp] play with the one-stop plan of cann target detection and recognition - learning notes 1 (initial experience)
The code spell checker plug-in avoids some specific vocabulary errors "XXX": unknown word.cspell
Review of some classic exercises of arrays
The most comprehensive multi-threaded application tutorial - summary in detail
Using JS to realize the linkage effect of form form's secondary menu
Function template learning record
Req.body in node.express is always undefind
Recycleview realizes horizontal sliding of overlapping items
Seekbar属性参考
Introduction to the usage of explain and the meaning of result field in MySQL
Koa2 learning
[C language] document processing and operation