jquery實(shí)現(xiàn)圖片列表鼠標(biāo)移入微動
本效果使用jQuery和CSS實(shí)現(xiàn)了圖片列表,當(dāng)鼠標(biāo)移入時(shí)圖片向左微動,移出則復(fù)原。
其中的jQuery事件使用mouseenter 和 mouseleave ,事件綁定方法使用新推薦的on方法。
代碼如下:
<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>jQuery實(shí)現(xiàn)圖片列表鼠標(biāo)移入微動_何問起</title><base target="_blank" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body, div, li, p, img, a {
margin: 0;
padding: 0;
}
.hovertreecontainer {
width: 370px;
margin: 50px auto;
}
.hovertreecontainer a {
text-decoration: none;
}
.hovertree-item-box {
height: 120px;
width: 185px;
position: relative;
padding: 10px;
box-sizing: border-box;
float: left;
}
.hovertree-item-box .title {
width: 80px;
height: 100%;
color: #4998a1;
font-size: 14px;
}
.hovertree-item-box.odd {
border-bottom: 1px solid #CCC;
border-right: 1px solid #CCC;
}
.hovertree-item-box.even {
border-bottom: 1px solid #CCC;
}
.hovertree-item-box.nobottom {
border-bottom: none;
}
.hovertree-item-box .hovertree-img-box {
width: 80px;
height: 80px;
overflow: hidden;
position: absolute;
right: 10px;
bottom: 5px;
}
.hovertree-img-box img {
width: 100%;
height: 100%;
}
.hovertreecontainer:after {
content: "";
display: block;
clear: both;
}
</style>
</head>
<body>
<div class="hovertreecontainer"><h2>jQuery實(shí)現(xiàn)圖片列表鼠標(biāo)移入微動</h2>
<a >
<div class="hovertree-item-box odd">
<div class="title">春節(jié)對聯(lián)</div>
<div class="hovertree-img-box"><img src="http://hovertree.com/hvtimg/201512/o9qashmi.gif"></div>
</div>
</a>
<a >
<div class="hovertree-item-box even">
<div class="title">下雨天</div>
<div class="hovertree-img-box"><img src="http://hovertree.com/hvtimg/201512/f748s0ko.jpg"></div>
</div>
</a>
<a >
<div class="hovertree-item-box odd">
<div class="title">磨砂玻璃</div>
<div class="hovertree-img-box"><img src="http://hovertree.com/hvtimg/201512/agagq0or.jpg"></div>
</div>
</a>
<a >
<div class="hovertree-item-box even">
<div class="title">網(wǎng)頁特效</div>
<div class="hovertree-img-box"><img src="http://hovertree.com/hvtimg/201512/r51a22uy.gif"></div>
</div>
</a>
<a >
<div class="hovertree-item-box odd nobottom">
<div class="title">何問起統(tǒng)計(jì)文件數(shù)</div>
<div class="hovertree-img-box"><img src="http://hovertree.com/hvtimg/bjafjd/iofopnro.png"></div>
</div>
</a>
<a >
<div class="hovertree-item-box even nobottom">
<div class="title">HovertreeImg</div>
<div class="hovertree-img-box"><img src="http://hovertree.com/hvtimg/201601/p3t2ldyr.png"></div>
</div>
</a>
<div><a >原文</a> <a >首頁</a> <a >特效</a></div>
</div>
<script type="text/javascript" src="http://down.hovertree.com/jquery/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$(function () {
$('.hovertreecontainer .hover'+'tree-item-box').on('mouseenter', function (ev) {
var oImgBox = $(this).find('.hovertree-img-box');
$(oImgBox).stop(true).animate({
right: '20px'
}, "normal");
}).on('mouseleave', function (ev) {
var oImgBox = $(this).find('.hovertree-img-box');
$(oImgBox).stop(true).animate({
right: '10px'
}, "normal");
});
});
</script>
</body>
</html>
以上就是本文的全部內(nèi)容,希望對大家有所幫助,同時(shí)也希望多多支持腳本之家!
相關(guān)文章
jquery.messager.js插件導(dǎo)致頁面抖動的解決方法
這盤文章介紹了jquery.messager.js插件導(dǎo)致頁面抖動的解決方法,有需要的朋友可以參考一下2013-07-07
超級酷和最實(shí)用的jQuery實(shí)例收集(20個(gè))
二十個(gè)超級酷和最實(shí)用的jQuery實(shí)例,對于使用和學(xué)習(xí)jquery的朋友是個(gè)不錯(cuò)的參考與學(xué)習(xí)資料。2010-04-04
推薦40個(gè)簡單的 jQuery 導(dǎo)航插件和教程(下篇)
在下面的集合中,你會發(fā)現(xiàn)很多便利的 jQuery 導(dǎo)航插件和有用的教程,幫助你實(shí)現(xiàn)充滿吸引力的網(wǎng)站導(dǎo)航,讓你網(wǎng)站更有組織性和交互性2012-09-09
jQuery實(shí)現(xiàn)級聯(lián)下拉框?qū)崙?zhàn)(5)
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)級聯(lián)下拉框的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02
淺談jQuery中 wrap() wrapAll() 與 wrapInner()的差異
本文結(jié)合W3School的文檔,分析了jQuery中 wrap() wrapAll() 與 wrapInner()的差異,并給出了圖文對比教程,非常的簡單實(shí)用,有需要的朋友可以參考下2014-11-11
jquery 元素控制(追加元素/追加內(nèi)容)介紹及應(yīng)用
一、在元素內(nèi)部/外部追加元素二、在元素的不同位置追加內(nèi)容三、在元素的開始位置追加內(nèi)容四、在不同元素的開始位置追加內(nèi)容等等,感興趣的朋友可以參考下哈2013-04-04

