jquery插件實(shí)現(xiàn)堆疊式菜單
更新時(shí)間:2021年04月23日 17:13:38 作者:阿飛超努力
這篇文章主要介紹了jquery插件實(shí)現(xiàn)堆疊式菜單,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
每天一個(gè)jquery插件-堆疊式菜單,供大家參考,具體內(nèi)容如下
堆疊式菜單
一個(gè)多頁(yè)面的特效
效果如下
代碼部分
<!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>頁(yè)面1</span></div> <div class="box box2" data-index="2"><span>頁(yè)面2</span></div> <div class="box box3" data-index="3"><span>頁(yè)面3</span></div> <div class="box box4" data-index="4"><span>頁(yè)面4</span></div> <div class="box box5" data-index="5"><span>頁(yè)面5</span></div> <div class="box box6" data-index="6"><span>頁(yè)面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>
思路解釋
布局的效果,很容易理解
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- 基于jquery的二級(jí)聯(lián)動(dòng)菜單實(shí)現(xiàn)代碼
- 用jquery實(shí)現(xiàn)下拉菜單效果的代碼
- 用jquery實(shí)現(xiàn)的一個(gè)超級(jí)簡(jiǎn)單的下拉菜單
- Jquery帶搜索框的下拉菜單
- jquery實(shí)現(xiàn)鼠標(biāo)滑過(guò)顯示二級(jí)下拉菜單效果
- jQuery點(diǎn)擊彈出下拉菜單的小例子
- jquery實(shí)現(xiàn)可點(diǎn)擊伸縮與展開的菜單效果代碼
- 用jquery寫的菜單從左往右滑動(dòng)出現(xiàn)
- 基于JQuery的簡(jiǎn)單實(shí)現(xiàn)折疊菜單代碼
- jquery實(shí)現(xiàn)左右滑動(dòng)菜單效果代碼
相關(guān)文章
超級(jí)酷和最實(shí)用的jQuery實(shí)例收集(20個(gè))
二十個(gè)超級(jí)酷和最實(shí)用的jQuery實(shí)例,對(duì)于使用和學(xué)習(xí)jquery的朋友是個(gè)不錯(cuò)的參考與學(xué)習(xí)資料。2010-04-04基于Jquery代碼實(shí)現(xiàn)支持PC端手機(jī)端幻燈片代碼
支持PC端手機(jī)端幻燈片代碼是一款支持移動(dòng)觸摸,支持鼠標(biāo)拖拽切換,支持帶進(jìn)度條的自動(dòng)播放模式,本文給大家分享一款基于jquery代碼實(shí)現(xiàn)支持pc端手機(jī)端幻燈片代碼,感興趣的朋友一起學(xué)習(xí)吧2015-11-11jQuery通過(guò)deferred對(duì)象管理ajax異步
這篇文章主要介紹了jQuery通過(guò)deferred對(duì)象管理ajax異步的相關(guān)資料,需要的朋友可以參考下2016-05-05jQuery實(shí)現(xiàn)點(diǎn)擊關(guān)注和取消功能
點(diǎn)贊,網(wǎng)絡(luò)用語(yǔ),表示“贊同”、“喜愛”。今天小編通過(guò)實(shí)例代碼給大家分享jQuery實(shí)現(xiàn)點(diǎn)擊關(guān)注和取消功能,需要的朋友參考下吧2017-07-07jquery的clone方法應(yīng)用于textarea和select的bug修復(fù)
textarea和select的值clone的時(shí)候會(huì)丟掉,在clone的時(shí)候?qū)al再重新賦值一下,如果知道這個(gè)了就加單了2014-06-06