本效果使用jQuery和CSS實現了圖片列表,當滑鼠移入時圖片向左微動,移出則復原。
其中的jQuery事件使用mouseenter 和 mouseleave ,事件綁定方法使用新推薦的on方法。
程式碼如下:
<!DOCTYPE html> <html> <head><meta name="viewport" content="width=device-width, initial-scale=1" /> <title>jQuery实现图片列表鼠标移入微动_何问起</title><base target="_blank" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css"> body, p, 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> <p class="hovertreecontainer"><h2 id="jQuery实现图片列表鼠标移入微动">jQuery实现图片列表鼠标移入微动</h2> <a href="http://hovertree.com/texiao/css/20/"> <p class="hovertree-item-box odd"> <p class="title">春节对联</p> <p class="hovertree-img-box"><img src="/static/imghwm/default1.png" data-src="http://hovertree.com/hvtimg/201512/o9qashmi.gif" class="lazy" alt="jquery實現圖片列表滑鼠移入微動" ></p> </p> </a> <a href="http://hovertree.com/hvtart/bjae/a6w6e2qg.htm"> <p class="hovertree-item-box even"> <p class="title">下雨天</p> <p class="hovertree-img-box"><img src="/static/imghwm/default1.png" data-src="http://hovertree.com/hvtimg/201512/f748s0ko.jpg" class="lazy" alt="jquery實現圖片列表滑鼠移入微動" ></p> </p> </a> <a href="http://hovertree.com/h/bjae/0st5ww13.htm"> <p class="hovertree-item-box odd"> <p class="title">磨砂玻璃</p> <p class="hovertree-img-box"><img src="/static/imghwm/default1.png" data-src="http://hovertree.com/hvtimg/201512/agagq0or.jpg" class="lazy" alt="jquery實現圖片列表滑鼠移入微動" ></p> </p> </a> <a href="http://hovertree.com/menu/texiao/"> <p class="hovertree-item-box even"> <p class="title">网页特效</p> <p class="hovertree-img-box"><img src="/static/imghwm/default1.png" data-src="http://hovertree.com/hvtimg/201512/r51a22uy.gif" class="lazy" alt="jquery實現圖片列表滑鼠移入微動" ></p> </p> </a> <a href="http://hovertree.com/h/bjaf/hwqtjwjs.htm"> <p class="hovertree-item-box odd nobottom"> <p class="title">何问起统计文件数</p> <p class="hovertree-img-box"><img src="/static/imghwm/default1.png" data-src="http://hovertree.com/hvtimg/bjafjd/iofopnro.png" class="lazy" alt="jquery實現圖片列表滑鼠移入微動" ></p> </p> </a> <a href="http://hovertree.com/h/bjaf/hovertreeimg.htm"> <p class="hovertree-item-box even nobottom"> <p class="title">HovertreeImg</p> <p class="hovertree-img-box"><img src="/static/imghwm/default1.png" data-src="http://hovertree.com/hvtimg/201601/p3t2ldyr.png" class="lazy" alt="jquery實現圖片列表滑鼠移入微動" ></p> </p> </a> <p><a href="http://hovertree.com/h/bjaf/4mv4wgmj.htm">原文</a> <a href="http://hovertree.com">首页</a> <a href="http://hovertree.com/menu/texiao/">特效</a></p> </p> <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>
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章
刺客信條陰影:貝殼謎語解決方案
4 週前ByDDD
Windows 11 KB5054979中的新功能以及如何解決更新問題
3 週前ByDDD
在哪裡可以找到原子中的起重機控制鑰匙卡
4 週前ByDDD
<🎜>:死鐵路 - 如何完成所有挑戰
1 個月前ByDDD
Atomfall指南:項目位置,任務指南和技巧
1 個月前ByDDD

熱工具

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3 Linux新版
SublimeText3 Linux最新版

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。