jQuery實(shí)現(xiàn)手風(fēng)琴小案例
本文實(shí)例為大家分享了jQuery實(shí)現(xiàn)手風(fēng)琴的具體代碼,供大家參考,具體內(nèi)容如下
代碼演示效果:
1.運(yùn)用jQuery,動(dòng)畫樣式進(jìn)行輪播圖切換
2.前提,需要引入animate.css(官網(wǎng)下載就有)
HTML代碼:
<head> <meta charset="UTF-8"> <title>手風(fēng)琴</title> <link rel="stylesheet" href="../animate.css"> <link rel="stylesheet" href="css/index.css"> <script src="../jquery-3.1.0.js"></script> <!-- <script src="js/手風(fēng)琴index.js"></script>--> </head> <body> <div class="bg"></div> <div class="bg"></div> <div class="bg"></div> <div class="bg bg-active"></div> <div class="main"> <ul> <li><div><p>穿越火線</p></div></li> <li><div><p>王者榮耀</p></div></li> <li><div><p>使命召喚</p></div></li> <li class="li-active"><div><p>英雄聯(lián)盟</p></div></li> </ul> </div> </body>
script代碼:
<script> $(function () { $("li").mouseenter(function () { //stop()阻止動(dòng)畫效果 $(this).stop().animate({width:"700px"},1000,"linear").fadeIn(); $(this).siblings("li").stop().animate({width:"100px"},1000,"linear").fadeIn(); $(".bg").eq($(this).index()).siblings(".bg").stop().fadeOut(); $(".bg").eq($(this).index()).stop().animate({top:"700px"},400,"linear").fadeIn(); }); }); </script>
css代碼:
*{ margin: 0; padding: 0; } html,body, .bg{ height: 700px; width: 1400px; overflow: hidden; } body{ position: relative; } .bg{ display: none; } .bg:nth-child(1){ background:url("../images/1.jpg")no-repeat center/cover; } .bg:nth-child(2){ background:url("../images/2.jpg")no-repeat center/cover; } .bg:nth-child(3){ background:url("../images/3.jpg")no-repeat center/cover; } .bg:nth-child(4){ background:url("../images/4.jpg")no-repeat center/cover; } /*大背景顯示*/ .bg-active{ display: block; } .main{ position: absolute; width: 1000px; height: 400px; /*background-color: pink;*/ left: 0; top: 0; right: 0; bottom: 0; margin: auto; } .main ul{ list-style: none; } .main ul li{ float: left; width: 100px; height: 400px; transition:right 1s; } /*小背景顯示*/ .main ul li.li-active{ width: 700px; height: 400px; } .main ul li:nth-child(1){ background: url("../images/1.jpg")no-repeat center/cover; } .main ul li:nth-child(2){ background: url("../images/2.jpg")no-repeat center/cover; } .main ul li:nth-child(3){ background: url("../images/3.jpg")no-repeat center/cover; } .main ul li:nth-child(4){ background: url("../images/4.jpg")no-repeat center/cover; } .main ul li div{ height: 400px; width: 100px; background-color: rgba(0,0,0,.5); } .main ul li div p{ color: #fff; padding: 40px; font-size: 20px; opacity: 0.5; }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- jQuery Easyui使用(一)之可折疊面板的布局手風(fēng)琴菜單
- jquery插件制作 手風(fēng)琴Panel效果實(shí)現(xiàn)
- jQuery制作效果超棒的手風(fēng)琴折疊菜單
- jQuery實(shí)現(xiàn)的簡(jiǎn)單手風(fēng)琴效果示例
- 基于Jquery代碼實(shí)現(xiàn)手風(fēng)琴菜單
- 基于jquery的slideDown和slideUp做手風(fēng)琴
- jquery實(shí)現(xiàn)手風(fēng)琴效果實(shí)例代碼
- jquery手風(fēng)琴特效插件
- Jquery組件easyUi實(shí)現(xiàn)手風(fēng)琴(折疊面板)示例
- jquery實(shí)現(xiàn)手風(fēng)琴效果
相關(guān)文章
清空元素html("") innerHTML="" 與 empty()的區(qū)別和應(yīng)用(推薦)
這篇文章主要介紹了清空元素html("")、innerHTML="" 與 empty()的區(qū)別和應(yīng)用,詳細(xì)介紹了三者之間的原理及應(yīng)用,需要的朋友可以參考下2017-08-08jquery選擇器和屬性對(duì)象的操作實(shí)例分析
這篇文章主要介紹了jquery選擇器和屬性對(duì)象的操作,結(jié)合實(shí)例形式分析了jquery選擇器與頁面元素屬性相關(guān)操作技巧,需要的朋友可以參考下2020-01-01使用jQuery制作浮動(dòng)工具欄的實(shí)例分享
這里所說的浮動(dòng)工具欄就是大家平時(shí)看到的社交網(wǎng)絡(luò)分享按鈕欄那樣的效果,可以做成浮動(dòng)效果且能上下移動(dòng),這里我們就來看一個(gè)使用jQuery制作頁面工具邊欄的實(shí)例分享.2016-05-05基于Jquery實(shí)現(xiàn)表格動(dòng)態(tài)分頁實(shí)現(xiàn)代碼
項(xiàng)目中經(jīng)常會(huì)對(duì)表格進(jìn)行分頁,以下運(yùn)用jquery對(duì)用戶管理中的用戶表格進(jìn)行分頁。2011-06-06jquery select 設(shè)置默認(rèn)選中的示例代碼
本篇文章主要是對(duì)jquery select 設(shè)置默認(rèn)選中的示例代碼進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2014-02-02jquery實(shí)現(xiàn)先淡出再折疊收起的動(dòng)畫效果
這篇文章主要介紹了jquery實(shí)現(xiàn)先淡出再折疊收起的動(dòng)畫效果,通過jquery鏈?zhǔn)讲僮鲗?shí)現(xiàn)頁面元素的漸變折疊與展開功能,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2015-08-08