jQuery實(shí)現(xiàn)圖片滑動效果
思路:當(dāng)鼠標(biāo)進(jìn)入元素時,觸發(fā)hover中的第一個函數(shù),離開時觸發(fā)hover中的第二個函數(shù)。
如圖所示:

代碼如下:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
}
ul{
width: 1000px;
margin: 0 auto;
}
li{
cursor: pointer;
border: 1px solid #fff;
display: inline-block;
width: 198px;
height: 250px;
float: left;
overflow: hidden;
background-color: #f7f7f7;
position: relative;
}
li .fade{
font-family: "微軟雅黑";
display: none;
width: 320px;
height: 270px;
background: #090;
position: absolute;
left: 0px;
top: 0px;
z-index: 19;
}
li .img1{
width: 110px;
height: 110px;
text-align: center;
position: absolute;
top: 22px;
right: 41px;
z-index: 99;
}
li .img2{
width: 110px;
height: 110px;
text-align: center;
position: absolute;
top: 22px;
left: -110px;
z-index: 99;
}
li .txt1{
width: 198px;
height: 100px;
color: #999999;
position: absolute;
top: 145px;
left: 0px;
z-index: 99;
text-align: center;
}
li .txt2{
width: 198px;
height: 100px;
color: #a9cf4f;
position: absolute;
top: 145px;
right: -240px;
z-index: 99;
text-align: center;
}
</style>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
</head>
<body>
<div class="main">
<ul>
<li>
<div class="fade"></div>
<div class="img1"><img src="img/1.png"></div>
<div class="img2"><img src="img/1-1.png"></div>
<div class="txt1">啦啦啦啦啦</div>
<div class="txt2">是是是是是</div>
</li>
<li>
<div class="fade"></div>
<div class="img1"><img src="img/2.png"></div>
<div class="img2"><img src="img/2-2.png"></div>
<div class="txt1">啦啦啦啦啦</div>
<div class="txt2">是是是是是</div>
</li>
<li>
<div class="fade"></div>
<div class="img1"><img src="img/1.png"></div>
<div class="img2"><img src="img/1-1.png"></div>
<div class="txt1">啦啦啦啦啦</div>
<div class="txt2">是是是是是</div>
</li>
<li>
<div class="fade"></div>
<div class="img1"><img src="img/2.png"></div>
<div class="img2"><img src="img/2-2.png"></div>
<div class="txt1">啦啦啦啦啦</div>
<div class="txt2">是是是是是</div>
</li>
</ul>
</div>
<script>
$(function(){
$("ul li").hover(function(){
$(this).children().stop(false,true);
$(this).find(".fade").fadeIn("slow");
$(this).find(".img1").animate({right:-110},400);
$(this).find(".img2").animate({left:41},400);
$(this).find(".txt1").animate({left:240},400);
$(this).find(".txt2").animate({right:0},400);
},function(){
$(this).children().stop(false,true);
$(this).find(".fade").fadeOut("slow");
$(this).find(".img1").animate({right:41},400);
$(this).find(".img2").animate({left:-110},400);
$(this).find(".txt1").animate({left:0},400);
$(this).find(".txt2").animate({right:-240},400);
})
})
</script>
</body>
</html>
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!
相關(guān)文章
jQuery下擴(kuò)展插件和拓展函數(shù)的寫法(匿名函數(shù)使用的典型例子)
這些年,javascript火起來了,主要?dú)w功于AJAX的推廣應(yīng)用,Web2.0的發(fā)展。。。于是,出現(xiàn)了很多的javascript框架。2010-10-10
用簡潔的jQuery方法toggleClass實(shí)現(xiàn)隔行換色
這篇文章主要介紹了用簡潔的jQuery方法toggleClass實(shí)現(xiàn)隔行換色,很簡單,但很實(shí)用,需要的朋友可以看看2014-10-10
jquery處理json數(shù)據(jù)實(shí)例分析
json數(shù)據(jù)是一種經(jīng)型的實(shí)時數(shù)據(jù)交互的數(shù)據(jù)存儲方法,使用到最多的應(yīng)該是ajax與json配合使用了,下面我來給大家介紹jquery處理json數(shù)據(jù)方法。2014-06-06
jQuery Ajax方法調(diào)用 Asp.Net WebService 的詳細(xì)實(shí)例代碼
我在這里將jQuery Ajax 調(diào)用Aspx.Net WebService 的幾個常用的方法做了一個整理,提供給正在找這方面內(nèi)容的博友,希望能給學(xué)習(xí)jQuery的朋友一點(diǎn)幫助,可以直接復(fù)制代碼運(yùn)行。2011-04-04
利用jquery實(shí)現(xiàn)下拉框的禁用與啟用
本文主要介紹了jquery實(shí)現(xiàn)下拉框的禁用與啟用的具體代碼。代碼清晰,容易理解。有需要的朋友可以參考下,希望會對大家有所幫助2016-12-12
實(shí)例解析jQuery中proxy()函數(shù)的用法
proxy()主要用于在同樣的上下文語境中指向另一個對象,下面我們就以實(shí)例解析jQuery中proxy()函數(shù)的用法,需要的朋友可以參考下2016-05-05
jQuery實(shí)現(xiàn)優(yōu)雅的彈窗效果(6)
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)優(yōu)雅彈窗效果 的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-02-02

