博主信息
博文 41
粉丝 0
评论 1
访问量 41577
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
jq鼠标经过图片突显效果
kong
原创
1388人浏览过

用到了 fadeTo () 动画效果

思路: 鼠标经过当前图片,图片上方的遮罩透明度为0,其父元素遮罩为半透明,鼠标离开恢复透明度为0。

效果:

01.gif


代码如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>鼠标经过突显效果</title>
</head>
<body>
<style>
*{
padding: 0;
margin: 0;
}
ol,ul{
padding: 0;
margin: 0;
list-style-type: none;
}
.box{
margin: 100px auto;
padding: 20px;
background: #000;
}

.box ul{
overflow: hidden;
margin: 0 auto;
width: 630px;
height: 420px;
}

.box ul li{
width: 200px;
height: 200px;
float: left;
margin-left: 10px;
margin-bottom: 10px;
background: #fff;
position: relative;
overflow: hidden;
}

.box ul li img{
width: 100%;
}

.box ul li p{
position: absolute;
width: 100%;
height: 100%;
background: #000;
opacity: 0;
filter: alpha(opacity=0);
z-index: 1;
top: 0;
left: 0;
}


</style>
<div>
<ul>
<li>
<img src="01.jpg" alt="">
<p></p>
</li>
<li>
<img src="02.jpg" alt="">
<p></p>
</li>
<li>
<img src="03.jpg" alt="">
<p></p>
</li>
<li>
<img src="01.jpg" alt="">
<p></p>
</li>
<li>
<img src="02.jpg" alt="">
<p></p>
</li>
<li>
<img src="03.jpg" alt="">
<p></p>
</li>
</ul>
</div>
<script src="jquery.min.js"></script>
<script>
$(function(){
var dring = 400;
        $(".box li").each(function() {
         $(this).mouseenter(function(event) {
         /* Act on the event */
         $(this).children('p').stop(true).fadeTo(dring,0).parent().siblings("li").children('p').stop(true).fadeTo(dring,0.3);
         });
        });

        $(".box ul").mouseout(function(event) {
         $(this).find('p').stop(true).fadeTo(dring,0)
        });
})
  
</script>
</body>
</html>


本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学