效果如下:

其实实现起来很简单,就是控制 宽 高的变化,然后给他加上transition 过度而已。觉得代码没什么难的地方,就不打注释了,如果哪里有不懂的话,可以直接评论呢。

直接上源码

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="./css/index.css">
</head> <body>
<div class="wra">
<ul class="content">
<li class="items">
<div class="inner">
<h2>bird</h2>
<div class="bg">
<div class="close"></div>
</div>
</div>
</li>
<li class="items">
<div class="inner">
<h2>bird</h2>
<div class="bg">
<div class="close"></div>
</div>
</div>
</li>
<li class="items">
<div class="inner">
<h2>bird</h2>
<div class="bg">
<div class="close"></div>
</div>
</div>
</li>
<li class="items">
<div class="inner">
<h2>bird</h2>
<div class="bg">
<div class="close"></div>
</div>
</div>
</li>
<li class="items">
<div class="inner">
<h2>bird</h2>
<div class="bg">
<div class="close"></div>
</div>
</div>
</li>
<li class="items">
<div class="inner">
<h2>bird</h2>
<div class="bg">
<div class="close"></div>
</div>
</div>
</li>
</ul>
</div>
<script src="./js/jquery.js"></script>
<script src="./js/index.js"></script>
</body> </html>

css代码:

*{
padding: 0;
margin: 0;
list-style: none;
box-sizing: border-box;
} :root,body,.wra{
width: 100%;
height: 100%;
}
.wra{
background-color: black;
display: flex;
justify-content: center;
align-items: center;
} .wra .content{
width: 80%;
height: 80%;
display: flex;
justify-content: space-between;
align-items: center;
overflow: hidden;
} .wra .content .items{
position: relative;
height: 100%;
width: 16%;
border-radius: 30px;
transition: height .5s linear, width .7s .5s linear;
}
.wra .content .items:hover .inner .bg{
opacity: 1;
}
.wra .content .items:hover h2{
font-size: 30px;
}
.wra .content .items h2{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
color: #fff;
font-size: 20px;
z-index: 1;
transition: font-size .3s , opacity .3s;
}
.wra.wra-active .content .items h2{
opacity: 0;
}
.wra .content .items .inner{
width: 100%;
height: 100%;
transition: transform .5s ;
}
.wra .content .items .inner .bg{
width: 100%;
height: 100%;
background-size: cover;
background-position: center center;
border-radius: 30px;
opacity: .5;
transition: opacity .3s;
}
.wra .content .items:nth-of-type(1) .inner .bg{
background-image: url('../img/1.jpg');
}
.wra .content .items:nth-of-type(2) .inner .bg{
background-image: url('../img/2.jpg');
}
.wra .content .items:nth-of-type(3) .inner .bg{
background-image: url('../img/3.jpg');
}
.wra .content .items:nth-of-type(4) .inner .bg{
background-image: url('../img/4.jpg');
}
.wra .content .items:nth-of-type(5) .inner .bg{
background-image: url('../img/5.jpg');
}
.wra .content .items:nth-of-type(6) .inner .bg{
background-image: url('../img/6.jpg');
} .wra .content .items.active{
width: 100%;
}
.wra .content .items.active .inner .bg{
opacity: 1;
}
.wra.wra-active .content .items:not(.active){
width: 0%;
height: 0%;
} .wra .content .items .inner{
transform: translateY(101%);
} .wra.init .content .items .inner{
transform: translateY(0%);
} .wra.init .content .items:nth-of-type(2) .inner{
transition-delay: .2s;
}
.wra.init .content .items:nth-of-type(3) .inner{
transition-delay: .3s;
}
.wra.init .content .items:nth-of-type(4) .inner{
transition-delay: .4s;
}
.wra.init .content .items:nth-of-type(5) .inner{
transition-delay: .5s;
}
.wra.init .content .items:nth-of-type(6) .inner{
transition-delay: .6s;
}
.wra .content .items .inner .bg .close{
opacity: 0;
transform: rotateZ(0deg);
}
.wra .content .items.active .inner .bg .close{
position: absolute;
right: 30px;
top: 30px;
width: 30px;
height: 30px;
opacity: 1;
transform: rotateZ(360deg);
}
.wra .content .items.active .inner .bg .close{
transition: opacity .3s linear 1s, transform .5s linear 1s;
}
.wra .content .items.active .inner .bg .close::after,.wra .content .items.active .inner .bg .close::before{
position: absolute;
content: "";
width: 30px;
height: 4px;
background-color: #fff;
top: calc(50% - 2px);
}
.wra .content .items.active .inner .bg .close::after{
transform: rotateZ(45deg);
}
.wra .content .items.active .inner .bg .close::before{
transform: rotateZ(-45deg);
}

jquery代码:

setTimeout(function(){
$('.wra').addClass('init');
},400)
$('.items').on('click', function(){
$(this).addClass('active');
$('.wra').addClass('wra-active');
})
$('.close').on('click', function(e){
e.stopPropagation();
$('.items').removeClass('active');
$('.wra').removeClass('wra-active');
})

利用css3实现照片列表展开小demo的更多相关文章

  1. Android学习小Demo(19)利用Loader来实时接收短信

    之前写过一篇文章<Android学习小Demo(13)Android中关于ContentObserver的使用>,在里面利用ContentOberver去监測短信URI内容的变化.我们先来 ...

  2. [置顶] 利用CXF发布webService的小demo

    其实webService的发布不仅仅只有xfire,今天,给大家介绍一下用CXF发布一个webService的小demo,CXF也是我做webService用的第一个框架... 先将相关的jar引进来 ...

  3. css3的一个小demo(箭头hover变化)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. jQuery/CSS3实现图片层叠展开特效

    这是一款基于jQuery和CSS3的图片层叠展开特效,让鼠标滑过图片时即可触发这些特效.其中有一款就像扇子展开收拢一样,看起来效果都非常不错.当然本文主要还是来分析一下用jQuery实现这一效果的方法 ...

  5. 超可爱 纯CSS3实现的小猪、小老鼠、小牛

    原文:超可爱 纯CSS3实现的小猪.小老鼠.小牛 利用纯CSS3绘制一些人物.动物.风景已经不是一件新鲜的事情了,主要是利用CSS3可以让直线变成任意的曲线,于是简单的矢量图形绘制对CSS3来说就小菜 ...

  6. 使用纯 CSS 实现 Google Photos 照片列表布局

    文章太长,因为介绍了如何一步一步进化到最后接近完美的效果的,不想读的同学可以直接跳到最后一个大标题之后看代码.demo及原理就好,或者也可以直接看下面这个链接的源代码. 不过还是建议顺序读下去,因为后 ...

  7. Nancy之基于Nancy.Owin的小Demo

    前面做了基于Nancy.Hosting.Aspnet和Nancy.Hosting.Self的小Demo 今天我们来做个基于Nancy.Owin的小Demo 开始之前我们来说说什么是Owin和Katan ...

  8. 利用CSS3实现图片无间断轮播图的实现思路

    前言:图片轮播效果现在在各大网站都是非常普遍的,以前我们都是通过postion的left or right来控制dom的移动,这里我要说的是利用css3来制作轮播!相比以前通过postion来移动do ...

  9. 利用CSS3实现圆角的outline效果的教程

    一.首先,outline是个很牛的东西1. border近亲outline和border是近亲,为什么这么讲呢?首先,都是给元素外面套框框的:其次,支持的属性值几乎都是一样的,例如,outline-s ...

随机推荐

  1. JDBC Statement PrepareStatement

    1.JDBC中Statement接口和PrepareStatement接口关系与区别 Statement接口不能使用占位符?,需要拼sql,所以没有setInt,setString等方法:Prepar ...

  2. cp: cannot stat: filepath Permission denied

    在执行 cp -r frompath topath时,报错cp: cannot stat: frompath Permission denied. 百度,google都没有找到解决方案,无意中发现,原 ...

  3. libhiredis.so.0.13: cannot open shared object file: No such file or directory in Unknown on line

    vim /etc/ld.so.conf添加 /usr/local/lib (此处为动态链接库的目录) ldconfig

  4. uniapp swiper高度自适应问题

    这里的话是想做一个比较常见的左右滑动更改tab的效果,引用了uview-ui中的u-tabs-swiper组件,需要结合swiper组件来使用 先来讲下主体思路:每个tab页(swiper-item) ...

  5. day78:luffy:前端对于token的认证&滑动验证码的实现

    目录 1.前端对于token的认证 2.滑动验证码 1.滑动验证码实现的原理 2.滑动验证码的代码实现 1.配置文件 2.前端实现:Login.vue 3.后端实现:改写jwt代码 1.前端对于tok ...

  6. OpenCV计算机视觉学习(9)——图像直方图 & 直方图均衡化

    如果需要处理的原图及代码,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/ComputerVisionPractice 1, ...

  7. Java学习的第五十五天

    1.例11.1继承学生类 import java.util.Scanner; import java.util.*; public class Cjava { public static void m ...

  8. JS对象创建的几种方式整理

    ​ 本文主要介绍了JS对象创建的几种方式 第一种:Object构造函数创建 var Person = new Object(); Person.name = 'Nike'; Person.age = ...

  9. [python学习手册-笔记]001.python前言

    001.python前言 ❝ 本系列文章是我个人学习<python学习手册(第五版)>的学习笔记,其中大部分内容为该书的总结和个人理解,小部分内容为相关知识点的扩展. 非商业用途转载请注明 ...

  10. react 实现组件嵌套以及子组件与父组件之间的通信

    当子组件触发onChange事件时,实际调用的是父组件中的handelSelect函数,通俗来说就是父组件通过属性handleSelect实现与子组件之间的通信. 父组件:SignupForm 子组件 ...