遮罩效果的焦点图

简介: 已经不是第一次写焦点图了。但是每一次写都有不同进步和完善。这次带来了遮罩效果的焦点图。设计思想:采用绝对定位,关于mask是设置遮罩层,这个图层位于最上面,关于pic是焦点图片。控制width,height,margin-left,margin-top,z-index属性,便可以实现漂亮的遮罩效果。

已经不是第一次写焦点图了。但是每一次写都有不同进步和完善。
这次带来了遮罩效果的焦点图。
设计思想:
采用绝对定位,关于mask是设置遮罩层,这个图层位于最上面,关于pic是焦点图片。
控制width,height,margin-left,margin-top,z-index属性,便可以实现漂亮的遮罩效果。

焦点图
简单的手风琴效果


下面演示最原始的效果:

<!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script> <style type="text/css"> *{margin:0px;padding:0px;} #focus{width: 500px; height: 300px;overflow: hidden; text-align: center; position: relative;} #focus .pic{position: absolute;top:0px;left:0px;} #focus .mask{opacity: 0.8; filter:alpha(opacity=80); position: absolute; top:50%; left: 50%; width:10px; height: 10px; margin-left: -5px; margin-right: -5px; z-index: 5;} </style> <script type="text/javascript"> $(function(){ var focus= $("#focus"); var mask = focus.find(".mask"); var fimgs = focus.find(".pic"); var count = fimgs.length; var cur=0; var bchange=true; var arrimgs=new Array("http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_grass.png","http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_factor.png","http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_heard.png","http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_round.png","http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_star.png"); setInterval(function(){ cur++; if(cur===count){cur=0;} fimgs.css({"top":"50%","left":"50%","width":"500px","margin-left":"-250px","height":"300px","margin-top":"-150px","z-index":"0"}); fimgs.eq(cur-1).css({"top":"50%","left":"50%","width":"500px","margin-left":"-250px","height":"300px","margin-top":"-150px","z-index":"1"}); fimgs.eq(cur).css({"top":"50%","left":"50%","width":"50px","margin-left":"-25px","height":"30px","margin-top":"-15px","z-index":"2"}).animate({"top":"50%","left":"50%","width":"500px","margin-left":"-250px","height":"300px","margin-top":"-150px"},500); mask.attr("src",arrimgs[ parseInt(Math.random()*arrimgs.length)]); if(bchange){ mask.css({"top":"50%","left":"50%","width":"10px","margin-left":"-5px","height":"10px","margin-top":"-5px","opacity":"0.8"}); bchange=false; } mask.animate({"top":"50%","left":"50%","width":"600px","margin-left":"-300px","height":"400px","margin-top":"-200px","opacity":"0"},800); bchange=true; },3000); }); </script> </head> <body> <div id="focus"> <img class="mask" alt="" src="heard.png" /> <img class="pic" width="500" height="300" alt="" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_1.jpg" style="z-index:1" /> <img class="pic" width="50" height="30" alt="" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_2.jpg" /> <img class="pic" width="50" height="30" alt="" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_3.jpg" /> <img class="pic" width="50" height="30" alt="" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_4.jpg" /> <img class="pic" width="50" height="30" alt="" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_5.jpg" /> </div> </body> </html>

目录
相关文章
|
3月前
鼠标经过图片图片放大效果
鼠标经过图片图片放大效果
27 0
|
2月前
|
机器学习/深度学习 人工智能
bigjpg图片放大
bigjpg图片放大
13 0
|
移动开发 HTML5
百叶窗图片切换
在线演示 本地下载
950 0
3d旋转动画焦点图
在线演示 本地下载
657 0
CSS3鼠标滑过图片3D旋转动画
在线演示       本地下载
1071 0
3d旋转焦点图
在线演示 本地下载
627 0
|
Web App开发 容器
CSS3实现京东图片鼠标滑过流光效果
京东首页从1F开始,左侧大图都有一个很有意思的效果,当你的鼠标滑过图片时,会有一层质感很强的流光从左侧不可见位置滑动到右侧不可见位置的效果。相较于淘宝的蒙版效果,个人感觉流光效果更好看一些。因此,本站一些图片也采用了这种流光效果,具体可鼠标滑过博文封面图预览。
1651 0