分类:
前端
先让大家看看效果图吧:
需要引入外来插件:
https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js
jquery.min.js
https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css
展示图片效果用法:
https://blog.csdn.net/qq_36545656/article/details/53872363
老马用法的案例:
https://www.cnblogs.com/fly_dragon/p/9146157.html
html:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <link rel="stylesheet" href="style.css"> <script src="js/jquery-3.3.1.min.js"></script> <script src="js/jquery.magnific-popup.min.js"></script> <link rel="stylesheet" href="css/magnific-popup.min.css"> </head> <body> <div class="content"> <div class="lin-width"> <h1>My Album</h1> <div class="boder"></div> <div class="Album"> <a href="img/71.jpg" class="image"> <img src="img/71.jpg" alt="" srcset=""> </a> <a href="img/93.jpg" class="image"> <img src="img/93.jpg" alt="" srcset=""> </a> <a href="img/104.jpg" class="image"> <img src="img/104.jpg" alt="" srcset=""> </a> <a href="img/156.jpg" class="image"> <img src="img/156.jpg" alt="" srcset=""> </a> <a href="img/171.jpg" class="image"> <img src="img/171.jpg" alt="" srcset=""> </a> <a href="img/264.jpg" class="image"> <img src="img/264.jpg" alt="" srcset=""> </a> <a href="img/265.jpg" class="image"> <img src="img/265.jpg" alt="" srcset=""> </a> <a href="img/river.jpg" class="image"> <img src="img/river.jpg" alt="" srcset=""> </a> </div> </div> </div> <script> $('.Album').magnificPopup({ delegate: 'a', type: 'image', gallery: { enabled: true } }) </script> </body> </html>
css:
*{ padding: 0; margin: 0; box-sizing: border-box; font-family: 'montserrat',sans-serif; } .content{ width: 100%; padding: 60px 0; } .lin-width{ width: 100%; max-width: 1200px; padding: 0 10px 10px 10px; margin: auto; background-color: #f1f1f1; } .lin-width h1{ text-align: center; /* 把字体全部转为字体 */ text-transform: uppercase; padding-top: 10px; } .boder{ width: 150px; height: 5px; background-color: #333; /* 居中 */ margin: 30px auto; } .Album{ /* 弹性合作 */ display: flex; /* 竖起 */ flex-wrap: wrap-reverse; /* 居中 */ justify-content: center; } .Album .image{ /* 每张占25%大小 */ flex: 25%; /* 超出隐藏 */ overflow: hidden; /* 可点击状态 */ cursor: pointer; } .Album .image img{ width: 100%; height: 100%; /* 4秒的过滤动画 */ transition: .4s; } .image:hover img{ /* 大小为自身的1.4倍 旋转15度 */ transform: scale(1.4) rotate(15deg); } /* 自适应 */ @media screen and (max-width:960px){ .Album .image{ flex: 33.3%; } } @media screen and (max-width:768px){ .Album .image{ flex: 50%; } } @media screen and (max-width:480px){ .Album .image{ flex: 100%; } }
视频教程:https://www.bilibili.com/video/av47766149
如有侵权,请留言!
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
评价
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术