您好,登錄后才能下訂單哦!
這篇文章主要介紹jquery插件怎么實(shí)現(xiàn)堆疊式菜單,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
jquery是一個(gè)簡(jiǎn)潔而快速的JavaScript庫(kù),它具有獨(dú)特的鏈?zhǔn)秸Z(yǔ)法和短小清晰的多功能接口、高效靈活的css選擇器,并且可對(duì)CSS選擇器進(jìn)行擴(kuò)展、擁有便捷的插件擴(kuò)展機(jī)制和豐富的插件,是繼Prototype之后又一個(gè)優(yōu)秀的JavaScript代碼庫(kù),能夠用于簡(jiǎn)化事件處理、HTML文檔遍歷、Ajax交互和動(dòng)畫,以便快速開發(fā)網(wǎng)站。
每天一個(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>
以上是“jquery插件怎么實(shí)現(xiàn)堆疊式菜單”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。