图片/图形

图片画廊鼠标滑过图片动画过渡特效

阿里云


这是一款使用纯 CSS3 制作的超酷图片画廊鼠标滑过图片动画过渡特效。该特效中,图片使用 flex 来进行网格布局,当鼠标滑过图片时,图片平滑向上移动,下方的图片描述信息被显示出来。

HTML 结构

该特效使用嵌套<div>的 HTML 结构,每一个 div.gallery-item 是一个卡片,里面包含了图片和描述信息。

也想出现在这里?联系我们
创客主机
  1. <div class="container">
  2.   <div class="gallery">
  3.     <div class="gallery-item">
  4.       <!-- 图片 -->
  5.       <div class="gallery-item-image">
  6.             <img src="img/1.jpg">
  7.           </div>
  8.           <!-- 图片描述信息 -->
  9.           <div class="gallery-item-description">
  10.             <h3>Image title</h3><span>......</span></div>
  11.         </div>
  12.     </div>
  13.  
  14.     ......
  15.  
  16.   </div>
  17. </div>

CSS 样式

画廊采用 flex 进行布局,这个画廊设置最大宽度和 100%的视口高度。

  1. .gallery{
  2.   width: 100%;
  3.   max-width: 960px;
  4.   min-height: 100vh;
  5.   margin: 2rem auto;
  6.  
  7.   display: -webkit-box;
  8.   display: -webkit-flex;
  9.   display: -ms-flexbox;
  10.   display: flex;
  11.  
  12.   -webkit-flex-wrap: wrap;
  13.       -ms-flex-wrap: wrap;
  14.           flex-wrap: wrap;
  15.  
  16.   -webkit-box-pack: center;
  17.   -webkit-justify-content: center;
  18.       -ms-flex-pack: center;
  19.           justify-content: center;
  20. }

画廊中的每一个图片卡片都设置了固定的宽度和高度,并设置了一些阴影效果。

  1. .gallery-item{
  2.   box-shadow: 2px 2px 8px -1px #3498DB;
  3.   width: 300px;
  4.   height: 300px;
  5.   margin: 10px;
  6.   background: #000;
  7.   position: relative;
  8.   cursor: pointer;
  9.   overflow: hidden;
  10. }

图片使用绝对定位,宽度和高度都等于卡片的宽度和高度,并设置了 0.5 秒的 ease 过渡动画效果。

  1. .gallery-item-image{
  2.   position: absolute;
  3.   width: 100%;
  4.   height: 100%;
  5.   background: lightblue;
  6.   z-index:20;
  7.   -webkit-transition:all .5s ease;
  8.   transition: all .5s ease;
  9.   bottom:0;
  10.   overflow: hidden;
  11. }

当鼠标滑过卡片时,移动图片的 bottom 属性,使图片向上移动。

  1. .gallery-item:hover .gallery-item-image{
  2.   bottom: 80px;
  3. }

完整的 CSS 样式代码请参考下载文件。

图片画廊鼠标滑过图片动画过渡特效

已有 363 人购买
  • 14c2
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!