国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

jQuery實現(xiàn)的感應(yīng)鼠標(biāo)懸停圖片色彩漸顯效果

2024-05-06 16:15:55
字體:
供稿:網(wǎng)友
這篇文章主要介紹了jQuery實現(xiàn)的感應(yīng)鼠標(biāo)懸停圖片色彩漸顯效果,涉及jQuery中hover、find、css等方法的使用技巧,需要的朋友可以參考下
 

本文實例講述了jQuery實現(xiàn)的感應(yīng)鼠標(biāo)懸停圖片色彩漸顯效果。分享給大家供大家參考。具體實現(xiàn)方法如下:

 

復(fù)制代碼代碼如下:
<!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>超個性的感應(yīng)鼠標(biāo)懸停圖片色彩漸顯效果</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--把下面代碼加到<head>與</head>之間-->
<style type="text/css">
ul.gallery {
    width: 750px; /*--Adjust width according to your scenario--*/
    list-style: none;
    margin: 0; padding: 0;
}
ul.gallery li {
    float: left;
    margin: 10px 0 10px 25px; 
    padding: 0;
    text-align: center;
    border: 1px solid #ccc;
    -moz-border-radius: 3px; /*--CSS3 Rounded Corners--*/
    -khtml-border-radius: 3px; /*--CSS3 Rounded Corners--*/
    -webkit-border-radius: 3px; /*--CSS3 Rounded Corners--*/
    display: inline; /*--Gimp Fix aka IE6 Fix - Fixes double margin bug--*/
}
ul.gallery li a.thumb {
    width: 336px; /*--Width of image--*/
    height: 240px; /*--Height of image--*/
    border-bottom: 1px solid #ccc;
    cursor: pointer;
}
ul.gallery li span { /*--Used to crop image--*/
    width: 336px;
    height: 240px;
    overflow: hidden;
    display: block;
}
ul.gallery li a.thumb:hover {
    background: #333; /*--Hover effect for browser with js turned off--*/
}
ul.gallery li h2 {
    font-weight: normal;
    margin: 0; 
    padding: 10px;
    background: #f0f0f0;
    border-top: 1px solid #fff; /*--Subtle bevel effect--*/
}
ul.gallery li a { 
     text-decoration: none; 
     color: #777; 
     display: block;
     font-size: 140%;
}
</style>
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $("ul.gallery li").hover(function() { //On hover...
        var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
        //Set a background image(thumbOver) on the <a> tag - Set position to bottom
        $(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
        //Animate the image to 0 opacity (fade it out)
        $(this).find("span").stop().fadeTo('normal', 0 , function() {
            $(this).hide() //Hide the image after fade
        });
    } , function() { //on hover out...
        //Fade the image to full opacity 
        $(this).find("span").stop().fadeTo('normal', 1).show();
    });
});
</script>
</head>
<body>
預(yù)覽效果時左下角會提示錯誤,而且看不到效果,刷新一下就可以看到效果了;當(dāng)然,在實際使用中,不會出現(xiàn)這樣的問題。<br>
<!--把下面代碼加到<body>與</body>之間-->
<ul class="gallery">
 <li>
  <a href="#" class="thumb"><span><img src="/html/txdm_2/images/20100904/336240.jpg" alt=""></span></a>
  <h2><a href="#">Sunflowa Media</a></h2>
 </li>
</ul>
</body>
</html>

 

希望本文所述對大家的jQuery程序設(shè)計有所幫助。


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 绵阳市| 长垣县| 武宣县| 石渠县| 广灵县| 广水市| 洛南县| 延寿县| 邵武市| 福海县| 韶山市| 江门市| 桦南县| 新疆| 呼伦贝尔市| 寿宁县| 泾阳县| 静海县| 福鼎市| 洪湖市| 闽清县| 治县。| 当阳市| 沙湾县| 闸北区| 乌兰浩特市| 临猗县| 缙云县| 东乡族自治县| 中山市| 平乡县| 宁城县| 波密县| 瑞金市| 武安市| 庐江县| 安丘市| 河西区| 百色市| 开阳县| 招远市|