tnblog
首页

flex好看的相册

119人阅读 2019/4/12 17:09 评论:0 手机浏览 收藏
分类: 前端

先让大家看看效果图吧:

需要引入外来插件:

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

如有侵权,请留言!

评价
!咖喱棒!
文章
6
评论
8
分类
16
关注
16
{{item.ArticleTitle}}
{{item.BlogName}} : {{item.Content}}