帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» jQuery仿QQ相册图片查看
jQuery仿QQ相册图片查看
浏览:587次
-
评论:0次
-
发布时间:2017-03-11
Html
Css
Js
<
>
×
html,body { width:100%; height:100%; position:relative; } * { padding:0; margin:0; list-style:none; } li img { width:200px; height:160px; margin-left:10px; } .wrap li { width:200px; height:158px; margin-left:10px; margin-top:10px; float:left; } .wrap { width:630px; height:340px; padding-top:50px; padding-left:50px; } .mask { width:100%; height:100%; background:rgba(0,0,0,0.6); position:fixed; top:0; } .mask img { width:600px; height:480px; position:absolute; top:0; left:0; right:0; bottom:0; margin:auto; } .btnl { font-size:100px; width:40px; height:70px; left:10px; top:0; bottom:0; margin:auto; position:absolute; } .btnr { font-size:100px; width:40px; height:70px; right:10px; top:0; bottom:0; margin:auto; position:absolute; } .close { width:30px; height:30px; position:absolute; top:10px; right:20px; font-size:50px; }
$(function(){ var warp=$('.wrap'), lis=$('.wrap >li'), index=0, mask=$('.mask'), close=$(".close"), btnl=$(".btnl"), btnr=$(".btnr"), imgs=$("img",warp) /*console.log(lis)*/ cw= mask.hide(); lis.on('click',function(){ var imgP=$(this).find('img').prop('src'); mask.show(); mask.find('img').prop('src',imgP); index=$(this).index(); }) close.on('click',function(){ mask.hide(); }) btnr.on('click',function(){ index++; if(index==lis.length){ index=0; } var imgP=lis.eq(index).find('img').prop('src'); $('img',mask).fadeOut(900).prop('src',imgP).fadeIn(900); }) btnl.on('click',function(){ index--; if(index<0){ index=lis.length-1; } var imgP=lis.eq(index).find('img').prop('src'); $('img',mask).fadeOut(900).prop('src',imgP).fadeIn(900); }) /*imgs.on('click',function(e){ var posX=e.pageX; if(posX>cw/2){ btnr.triggerHandler('click') }else{ btnl.triggerHandler('click') } })*/ $(document).on('dbclick',mask,function(){ /*var obj=e.target; $(!$(obj).is('img')&&!$(obj).is('btnl')&&!$(obj).is('btnr')&&!$(obj).is('obj'))*/ mask.hide() }) })
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
2.1.1
<!doctype html><html><head><meta charset="utf-8"><title>jQuery仿QQ相册图片查看-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/2.1.1/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:用代码实现图片弹出层查看
JS计算时间差
JS实现搜索功能
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
587
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值