jquery實(shí)現(xiàn)圖片列表鼠標(biāo)移入微動(dòng)
本效果使用jQuery和CSS實(shí)現(xiàn)了圖片列表,當(dāng)鼠標(biāo)移入時(shí)圖片向左微動(dòng),移出則復(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)移入微動(dòng)_何問(wèn)起</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)移入微動(dòng)</h2> <a > <div class="hovertree-item-box odd"> <div class="title">春節(jié)對(duì)聯(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)頁(yè)特效</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">何問(wèn)起統(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 >首頁(yè)</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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家有所幫助,同時(shí)也希望多多支持腳本之家!
相關(guān)文章
jQuery關(guān)鍵詞說(shuō)明插件cluetip使用指南
我們?cè)谧鰓eb項(xiàng)目的時(shí)候,經(jīng)常會(huì)使用到提示效果。html自帶的提示效果是label標(biāo)簽的title,但是這個(gè)效果過(guò)于簡(jiǎn)單和難看,并且不方便調(diào)整樣式。今天我偶然發(fā)現(xiàn)個(gè)jQuery的插件,可以很方便的做出漂亮的提示效果。2015-04-04jQuery實(shí)現(xiàn)表格隔行及滑動(dòng),點(diǎn)擊時(shí)變色的方法【測(cè)試可用】
這篇文章主要介紹了jQuery實(shí)現(xiàn)表格隔行及滑動(dòng),點(diǎn)擊時(shí)變色的方法,可實(shí)現(xiàn)表格隔行變色以及鼠標(biāo)滑過(guò)與點(diǎn)擊時(shí)變色的功能,涉及jQuery響應(yīng)鼠標(biāo)事件及頁(yè)面元素樣式動(dòng)態(tài)改變的相關(guān)技巧,需要的朋友可以參考下2016-08-08使用Jquery打造最佳用戶體驗(yàn)的登錄頁(yè)面的實(shí)現(xiàn)代碼
使用Jquery打造最佳用戶體驗(yàn)的登錄頁(yè)面的實(shí)現(xiàn)代碼,改用jquery使用ajax異步驗(yàn)證,并在驗(yàn)證的過(guò)程中將頁(yè)面元素設(shè)置為不可用,防止重復(fù)登錄。2011-07-07解決Jquery下拉框數(shù)據(jù)動(dòng)態(tài)獲取的問(wèn)題
下面小編就為大家分享一篇解決Jquery下拉框數(shù)據(jù)動(dòng)態(tài)獲取的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-01-01jQuery 開發(fā)者應(yīng)該注意的9個(gè)錯(cuò)誤
jQuery 開發(fā)者應(yīng)該注意的9個(gè)錯(cuò)誤,使用jquery的朋友可以參考下2012-05-05jQuery實(shí)現(xiàn)簡(jiǎn)單五子棋游戲
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)簡(jiǎn)單五子棋游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-05-05Jquey拖拽控件Draggable使用方法(asp.net環(huán)境)
使用時(shí)首先依次引用Jquery,Jquery-Ui ,Draggable三個(gè)Js。然后在js中編寫相應(yīng)的代碼,相關(guān)代碼說(shuō)明請(qǐng)看程序中的注釋。2010-09-09