本文實例講述了jQuery實作仿QQ空間裝扮預覽圖片的滑鼠提示效果程式碼。分享給大家參考,具體如下:
這是一款仿騰訊網QQ空間裝扮預覽圖片的滑鼠提示效果,感應滑鼠顯示圖片的介紹訊息,當你把滑鼠移到圖片上的時候,圖片的背景會有所變化,並會顯示這張圖片的對應文字內容,是QQ空間使用過的效果。
運作效果截圖如下:
線上示範網址如下:
http://demo.jb51.net/js/2015/jquery-f-qq-zone-pic-view-codes/
具體程式碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>仿QQ空间装扮预览图片的鼠标提示效果</title> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <style type="text/css"> *{margin:0;padding:0;font-size:12px;line-height:150%;} .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;} .clearfix{display:inline-block;} #wrap{width:900px;margin:0 auto;} .good_list{padding:0 0 30px 13px;background:#f8f8f8;border:1px solid #eaeaea;margin-top:50px;} .item{float:left;margin:13px 13px 0 0;position:relative;} .good{padding:8px;} .goodOp{padding:2px;border:1px solid #a8a8a8;width:180px;background:#fff;font-size:0;} .goodHover{padding:0px;position:absolute;z-index:99666669;top:-40px;left:-4px;width:210px;height:204px;} .goodHd{background:url(images/imgHover.png);width:210px;height:204px;} .goodHd h2{font-size:12px;text-align:center;padding-top:12px;} .goodHd p{color:#9c9c9c;text-align:center;} .goodHd .img{padding-left:12px;} </style> <script src="jquery-1.6.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $("#list>.item").hover(function(){ $(this).find(".goodHover").show(); },function(){ $(this).find(".goodHover").hide(); }); }); </script> </head> <body> <div id="wrap"> <div class="good_list clearfix" id="list"> <div class="item" style="z-index:10"> <div class="good"> <div class="goodOp"><img src="images/1.gif"></div> </div> <div class="goodHover" style="display:none"> <div class="goodHd"> <h2>西班牙</h2> <p>点击图片预览装扮</p> <div class="img"> <div class="goodOp"><img src="images/1.gif"></div> </div> </div> </div> </div> <div class="item" style="z-index:9"> <div class="good"> <div class="goodOp"><img src="images/2.gif"></div> </div> <div class="goodHover" style="display:none"> <div class="goodHd"> <h2>西班牙</h2> <p>点击图片预览装扮</p> <div class="img"> <div class="goodOp"><img src="images/2.gif"></div> </div> </div> </div> </div> <div class="item" style="z-index:8"> <div class="good"> <div class="goodOp"><img src="images/3.gif"></div> </div> <div class="goodHover" style="display:none"> <div class="goodHd"> <h2>西班牙</h2> <p>点击图片预览装扮</p> <div class="img"> <div class="goodOp"><img src="images/3.gif"></div> </div> </div> </div> </div> <div class="item" style="z-index:7"> <div class="good"> <div class="goodOp"><img src="images/4.gif"></div> </div> <div class="goodHover" style="display:none"> <div class="goodHd"> <h2>西班牙</h2> <p>点击图片预览装扮</p> <div class="img"> <div class="goodOp"><img src="images/4.gif"></div> </div> </div> </div> </div> </div> </div> </div> </body> </html>
希望本文所述對大家jQuery程式設計有所幫助。