用jquery怎样做堆叠式菜单效果?
Admin 2021-09-17 群英技术资讯 823 次浏览
之前我们了解了很多样式的菜单,例如下拉式菜单、悬浮式菜单等等,今天我们来了解一下堆叠式菜单,这篇文就主要给大家分享用jquery插件实现堆叠式菜单效果,下文代码有一定的参考价值,感兴趣的朋友可以参考。
一个多页面的特效

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>堆叠式菜单</title>
<script src="js/jquery-3.4.1.min.js"></script>
<style>
* {
margin: 0px;
padding: 0px;
}
#boxs {
position: fixed;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
background-color: lightgray;
}
.box {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding-top: 10px;
padding-left: 70px;
font-weight: bold;
color: white;
transition: all 0.5s linear;
}
.box1 {
background-color: #1abc9c;
z-index: 1;
}
.box2 {
background-color: #2ecc71;
z-index: 2;
}
.box3 {
background-color: #3498db;
z-index: 3;
}
.box4 {
background-color: #9b59b6;
z-index: 4;
}
.box5 {
background-color: #34495e;
z-index: 5;
}
.box6 {
background-color: #f1c40f;
z-index: 6;
}
#btn {
color: black;
z-index: 9;
position: fixed;
width: 30px;
height: 30px;
/* background-color:lightgray; */
top: 5px;
left: 10px;
font-size: 30px;
cursor: pointer;
transition: all 0.3s linear;
display: flex;
justify-content: center;
align-items: center;
}
#btn:hover {
color: white;
font-weight: bold;
}
#btn.check {
transform: rotate(135deg);
color: white;
font-weight: bold;
}
.box.check{
z-index: 99;
}
.box span{
cursor: pointer;
}
</style>
</head>
<body>
<div id="btn">×</div>
<div id="boxs">
<div class="box box1" data-index="1"><span>页面1</span></div>
<div class="box box2" data-index="2"><span>页面2</span></div>
<div class="box box3" data-index="3"><span>页面3</span></div>
<div class="box box4" data-index="4"><span>页面4</span></div>
<div class="box box5" data-index="5"><span>页面5</span></div>
<div class="box box6" data-index="6"><span>页面6</span></div>
</div>
</body>
</html>
<script>
$(document).ready(function() {
$("#btn").click(function() {
$(this).toggleClass("check");
if($(this).hasClass('check')){
$(".box").removeClass('check');
$(".box").arr().forEach(item=>{
var index = parseInt(item.attr("data-index"));
item.css({
'top':40*index+'px',
'left':40*index+'px'
})
})
}else{
$(".box").arr().forEach(item=>{
var index = parseInt(item.attr("data-index"));
item.css({
'top':'0px',
'left':'0px'
})
})
}
})
$(".box span").click(function(){
$(".box").parent().removeClass('check');
$(this).parent().addClass('check');
$("#btn").click();
})
$.prototype.arr = function() {
var that = this;
var arr = [];
for (var i = 0; i < that.length; i++) {
arr.push($(that[i]));
}
return arr;
}
})
</script>
关于jquery插件实现堆叠式菜单效果就分享到这了,布局的效果,很容易理解。如果还想要了解更多样式的菜单,大家可以关注群英网络其它相关文章。
文本转载自脚本之家
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了详解vue-router的导航钩子(导航守卫),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
node服务CPU过高怎么办?怎么排查?下面本篇文章给大家整理分享下node服务CPU过高的排查思路,希望对大家有所帮助!
JS中的String.raw方法,下文有实例供大家参考,对大家了解操作过程或相关知识有一定的帮助,而且实用性强,希望这篇文章能帮助大家,下面我们一起来了解看看吧。
这篇文章主要介绍了antd table按表格里的日期去排序操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
这篇文章主要为大家详细介绍了js实现有趣的倒计时效果,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008