首页 > 作文

CSS 实现 图片鼠标悬停折叠效果

更新时间:2023-04-03 20:08:50 阅读: 评论:0

css 实现 图片鼠标悬停折叠效果

1. 实现要点

折叠是由多个块级元素来完成的;图片是以背景图片的方式呈现出来的;给每个块级元素设置同一张背景图片,通过background-position来控制显示的区域(类似于雪碧图);通过ransform属性来实现折叠效果;整个包裹div的大小就是图片的原大小,如果更改了尺寸,需要调整background-size等属性调整背景图片大小

2. 效果展示

3. 源码

<!doctype html><html lang="en"><head>  <meta chart="utf-8">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>hover-folder</title>  <style>    html,    body,    ul,    li {      margin: 0;      padding: 0    }    ul {      list-style: none;      display: block;    }    body {      width: 100%;      height: 100vh;    }    .container {      wi二建市政答案2021dth: 100%;      height: 100%;      /* background-color: aqua; */      display: flex;      justify-content: center;      align-items: center;      transform: scale(0.5);    }    .wrap {      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .5);      width: 1280px;      height: 854px;      font-size: 0;      line-height: 0;      position: relative;    }    .image {      cursor: pointer;    }    .abs-wrap {      height: 100%;      width: 100%;      /* top: 0;      left: 0; */      /* position: absolute; */      z-index: 10;    }    .abs-wrap:hover>.abs:nth-child(2) {      transform: matrix(0.8, -0.2, 0, 1, -1, 0);    }    .abs-wrap:hover>.abs:nth-child(3) {      transform: matrix(0.8, 0.2, 0, 1, -53, -50);    }    .abs-wrap:hover>.abs:nth-child(4) {      transform: matrix(0.8, -0.2, 0, 1, -105, 0);    }    .abs-wrap:hover>.abs:nth-child(5) {      transform: matrix(0.8, 0.2, 0, 1, -157, -50);  有哪些it培训机构  }    .abs {  七夕祝词    transform-style: prerve-3d;      transform-origin: left center;      transition: .4s ea-in-out;      width: 20%;      height: 100%;      /* background-color: rgba(0, 0, 0, .5); */      display: inline-block;      background-size: 100%;      background: url('https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&c=1600577868615&di=d2979a54604ecb409e3329527d0220fa&imgtype=0&src=http%3a%2f%2ft9.baidu.com%2fit%2fu%3d29311073%2c358824429%26fm%3d79%26app%3d86%26f%3djpeg%3fw%3d1280%26h%3d854');    }    .abs:nth-child(1) {      background-position: 0% 0%;    }    .abs:nth-child(2) {      background-position: 25% 0%;    }    .abs:nth-child(3) {      background-position: 50% 0%;    }    .abs:nth-child(4) {      background-position: 75% 0%;    }    .abs:nth-child(5) {      background-position: 100% 0%;    }  </style></head><body>  <div class="container">    <div class="wrap">      <ul class="abs-wrap">        <li class="abs"></li>        <li class="abs"></li>        <li class="abs"></li>        <li class="abs"></li>        <li class="abs"></li>      </ul>    </div>  </div></body></html>

总结

到此这篇关于css 实现 图片鼠标悬停折叠效果的文章就介绍到这了,更多相关css图片鼠标悬停折叠内容请搜索www.887551.c奕的组词om以前的文章或继续浏览下面的相力拔山兮关文章,希望大家以后多多支持www.887551.com!

本文发布于:2023-04-03 20:08:48,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/4a094df75a7aea4c391cad65ad953afd.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:CSS 实现 图片鼠标悬停折叠效果.doc

本文 PDF 下载地址:CSS 实现 图片鼠标悬停折叠效果.pdf

下一篇:返回列表
标签:鼠标   图片   效果   文章
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图