用jquery怎样做堆叠式菜单效果?
Admin 2021-09-17 群英技术资讯 623 次浏览
之前我们了解了很多样式的菜单,例如下拉式菜单、悬浮式菜单等等,今天我们来了解一下堆叠式菜单,这篇文就主要给大家分享用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进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
用JavaScript怎样做查询快递单号的功能?一些朋友可能每天都会收到或者寄出很多快递,因此查询快递单号的功能是很重要的,本文给分享模拟京东快递单号查询的功能,实现效果及代码如下,感兴趣的朋友可以参考。
目录前言例子1. 模块加载2. jsonp动态加载script3. 执行异步脚本4. webpackJsonpCallback5. 执行异步模块代码流程图总结前言在vue中我们经常用到动态导入页面组件,那么它是如何实现的呢,本文将通过简单的案例,快速了解实现原理例子// index.jsimport(./test).t
这篇文章主要介绍了vue父子组件的互相传值和调用,帮助大家更好的理解和学习使用vue框架,感兴趣的朋友可以了解下
这篇文章主要介绍了vue2.x 从vue.config.js配置到项目优化,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Javascript 完全套用了 Java 的位运算符,包括按位与&、按位或|、按位异或^、按位非~、左移<<、带符号的右移>>和用0补足的右移>>>。这套运算符针对的是整数,所以对 JavaScript 完全无用,因为 JavaScript 内部,所有数字都保存为双精度浮点数。
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008