美文网首页
简单导航栏

简单导航栏

作者: msqt | 来源:发表于2019-02-07 22:26 被阅读0次

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>导航栏</title>
</head>
<style>
.navigation{
position: relative;
left:0;
top:0;
width:100px;
height:600px;
border:1px solid #000;
}
.navigation .title{
float:left;
width:100%;
/height:150px;/
height: 30px;
border-bottom:1px solid #000;
text-align: center;
line-height: 30px;
overflow: hidden;
cursor: pointer;
background: #f1f1f1;
transition:height 0.5s;
}
.navigation .title span{
float:left;
width:100%;
height:30px;
border-bottom:1px solid #000;
text-align: center;
font-size: 20px;
line-height: 30px;
}
.navigation .title .chile-child{
float:left;
width:100%;
height:30px;
text-align: center;
font-size: 15px;
line-height: 30px;
}
.active{
background: #4CAF50;
}
</style>
<body>
<div class="navigation">
<div class="title">
<span class="active">首页</span>
</div>
<div class="title">
<span>视频</span>
<div class="chile-child">喜剧</div>
<div class="chile-child">恐怖悬疑</div>
<div class="chile-child">功夫</div>
<div class="chile-child">科幻</div>
</div>
<div class="title">
<span>音乐</span>
<div class="chile-child">流行</div>
<div class="chile-child">摇滚</div>
<div class="chile-child">电子</div>
<div class="chile-child">轻音乐</div>
</div>
<div class="title">
<span>小说</span>
<div class="chile-child">恐怖</div>
<div class="chile-child">玄幻</div>
<div class="chile-child">言情</div>
<div class="chile-child">都市</div>
</div>
</div>
</body>
<script>
let titles=document.querySelectorAll(".title span");
let links=document.querySelectorAll(".chile-child");
let boxs=[];
for(let i=0;i<titles.length;i++){
let obj={
'is_choose':false
}
boxs.push(obj);
}
for(let i=0;i<titles.length;i++){
titles[i].addEventListener("click",function(){
for(let j=0;j<titles.length;j++){
if(j===i){
titles[j].setAttribute('class','active');
}else{
titles[j].setAttribute('class','')
}
}
if(!boxs[i].is_choose){
this.parentNode.style.height=150+'px';
}else{
this.parentNode.style.height=30+'px';
}
boxs[i].is_choose=!boxs[i].is_choose;
})
}
for(let i=0;i<links.length;i++){
links[i].addEventListener('click',function(){
console.log(this);
})
}
</script>
</html>

image.png

相关文章

  • 超简单!!! iOS设置状态栏、导航栏按钮、标题、颜色、透明度,

    超简单!!! iOS设置状态栏、导航栏按钮、标题、颜色、透明度,偏移等 超简单!!! iOS设置状态栏、导航栏按钮...

  • BottomNavigationView的属性设置

    底部导航栏 底部导航栏的使用比较常见,目前常用的APP几乎都是使用底部导航栏将内容分类。底部导航栏的实现也比较简单...

  • 简单导航栏

    导航栏 .navigation{position: relative;l...

  • [JavaScript 实例] 导航栏几种常见样式

    这里记录下导航栏几种常见的样式,仅供大家参考。 导航栏1 (原生 JS 代码) 比较常见也比较简单的导航栏 ,用的...

  • iOS-导航栏,状态栏

    包括iOS状态栏,导航栏,TabBar,滑动手势问题等 1.超简单!!! iOS设置状态栏、导航栏按钮、标题、颜色...

  • 导航栏的显示和隐藏问题

    需求:看不到导航栏,图片置顶 如果简单的隐藏导航栏或设置导航栏背景色为透明的话 会出现切换时候有黑色区域,如下图 ...

  • iOS相关

    超简单!!! iOS 设置状态栏、导航栏按钮、标题、颜色、透明度,偏移等 // 一行代码搞定导航栏颜色navBar...

  • 导航栏的设置 背景 线

    一、设置导航栏底线 简单获取底线 2.单个页面设置隐藏显示 二、设置导航栏背景图1.设置导航栏背景图所需的各个尺寸...

  • swift-导航栏

    swift-导航栏直接上代码 导航栏整体背景颜色 导航栏左侧按钮 自定义 导航栏左侧 隐藏 导航栏右侧图片 参考:...

  • iOS 状态栏(statusbar)导航栏(navigation

    导航栏透明 导航栏渐变 状态栏字体颜色改变 导航栏隐藏如果导航栏自定义度高,需要完全自己重写,可以隐藏原来的导航栏...

网友评论

      本文标题:简单导航栏

      本文链接:https://www.haomeiwen.com/subject/llagsqtx.html