jQuery缩略图遮罩层

jQuery缩略图遮罩层

本文的图片遮罩层是仿照百度的图片效果,当鼠标悬浮在某个遮罩层的时候,阴影层就停留在当前图片,遮罩层会一直随着鼠标移动。

淘建站为您提供更多_图片代码_遮罩层_动画_遮罩层,在此特别感谢您对我们的支持与厚爱!

查看演示

演示不了,点击反馈

加入收藏

下载 435 次

打赏作者

觉得不错,可打赏下作者

下载资源

免费共享

特别说明:本站资源来自网友发布分享,仅供学习与参考,请勿用于商业用途,若有侵权请联系删除(272966172@qq.com)。
分类:图片代码 > 遮罩层 难易程度:初级

遮罩层样式

.mask{width:100%;height:100%;background:#000;position: absolute;display: none;opacity:0.5;}

图片和遮罩层结构

<div class="page_container">
    <div class="container">
        <img src="sucaiq.jpg" width="220" height="210" alt="http://www.sucaiq.com" />
        <div class="mask"></div>
    </div>
    <div class="container">
        <img src="sucaiq.jpg" width="220" height="210" alt="" />
        <div class="mask"></div>
    </div>
</div>

鼠标悬浮和离开图片事件

$(".container").bind("mouseenter mouseleave", function(e) {
    var w = $(this).width();
    var h = $(this).height();
    var x = (e.pageX - this.offsetLeft - (w / 2)) * (w > h ? (h / w) : 1);
    var y = (e.pageY - this.offsetTop - (h / 2)) * (h > w ? (w / h) : 1);
    //alert(x);
    var direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
    //direction的值为“0,1,2,3”分别对应着“上,右,下,左”
    var eventType = e.type;
    //alert(e.type);
    if (e.type == 'mouseenter') {
        if (direction == 0) {
            $(this).find('.mask').css({'display': 'block', 'top': -h + 'px', 'left': '0px'}).animate({'top': '0px'});
        } else if (direction == 1) {
            $(this).find('.mask').css({'display': 'block', 'left': w + 'px', 'top': '0px'}).animate({'left': '0px'});
        } else if (direction == 2) {
            $(this).find('.mask').css({'display': 'block', 'top': h + 'px', 'left': '0px'}).animate({'top': '0px'});
        } else if (direction == 3) {
            $(this).find('.mask').css({'display': 'block', 'left': -w + 'px', 'top': '0px'}).animate({'left': '0px'});
        }
    } else {
        if (direction == 0) {
            $(this).find('.mask').animate({'top': -h + 'px'});
        } else if (direction == 1) {
            $(this).find('.mask').animate({'left': w + 'px'});
        } else if (direction == 2) {
            $(this).find('.mask').animate({'top': h + 'px'});
        } else if (direction == 3) {
            $(this).find('.mask').animate({'left': -w + 'px'});
        }
    }
});

声明:本资料由淘建站会员提供,如转载注明来源,资料来源淘建站免费素材库:https://www.taojz.cn/texiao/772.html
jQuery缩略图遮罩层 希望对你有帮助,感谢您的支持!
  • html5动漫风格的引导页加载动画特效

    html5动漫风格的引导页加载动画特效

  • jquery制作创建单页动画404页面

    jquery制作创建单页动画404页面

  • html5 svg适用于手机端播放器按钮动画特效

    html5 svg适用于手机端播放器按钮动画特效

  • jQuery仿qq投票统计动画效果

    jQuery仿qq投票统计动画效果

  • jQuery开启百宝箱摇头效果

    jQuery开启百宝箱摇头效果

  • jquery.easing动画插件

    jquery.easing动画插件

  • html5交互设计乐器演奏动画特效

    html5交互设计乐器演奏动画特效

  • 一张图片的动画效果的演示

    一张图片的动画效果的演示

  • 红星放金光动画

    红星放金光动画

  • html5鼠标悬停叠加图片弹性动画特效

    html5鼠标悬停叠加图片弹性动画特效

  • html5 canvas绘制逼真3D瀑布流动画特效

    html5 canvas绘制逼真3D瀑布流动画特效

  • css3怪物表情动画特效

    css3怪物表情动画特效

  • 留言(0)
    头像
     阿里云限量代金券,戳我领取
    1 2