jQuery實現(xiàn)手風琴小案例
更新時間:2021年04月11日 08:53:10 作者:休息休息夏
這篇文章主要為大家詳細介紹了jQuery實現(xiàn)手風琴小案例,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了jQuery實現(xiàn)手風琴的具體代碼,供大家參考,具體內(nèi)容如下
代碼演示效果:

1.運用jQuery,動畫樣式進行輪播圖切換
2.前提,需要引入animate.css(官網(wǎng)下載就有)

HTML代碼:
<head>
<meta charset="UTF-8">
<title>手風琴</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/手風琴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()阻止動畫效果
$(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;
}
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
jquery實現(xiàn)漫天雪花飛舞的圣誕祝福雪花效果代碼分享
這篇文章主要介紹了jquery實現(xiàn)漫天雪花飛舞的圣誕祝福雪花效果,很浪漫,感興趣的小伙伴們可以參考一下2015-08-08
EasyUI Combobox設(shè)置默認值 獲取text的方法
這篇文章主要介紹了EasyUI Combobox設(shè)置默認值 獲取text的方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-11-11
Zero Clipboard實現(xiàn)瀏覽器復(fù)制到剪貼板的方法(多個復(fù)制按鈕)
這篇文章主要介紹了Zero Clipboard實現(xiàn)瀏覽器復(fù)制到剪貼板的方法,帶有多個復(fù)制按鈕效果,涉及jQuery插件ZeroClipboard.js具體使用步驟與相關(guān)技巧,需要的朋友可以參考下2016-03-03
jQuery的實現(xiàn)原理的模擬代碼 -2 數(shù)據(jù)部分
在 jQuery 中,可以對每一個 DOM 對象保存私有的數(shù)據(jù)。2010-08-08

