CSS如何實(shí)現(xiàn)圖片鼠標(biāo)懸停折疊效果

這篇文章給大家分享的是有關(guān)CSS如何實(shí)現(xiàn)圖片鼠標(biāo)懸停折疊效果的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。

創(chuàng)新互聯(lián)專注于船營(yíng)企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,商城網(wǎng)站制作。船營(yíng)網(wǎng)站建設(shè)公司,為船營(yíng)等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)

CSS 實(shí)現(xiàn) 圖片鼠標(biāo)懸停折疊效果

1. 實(shí)現(xiàn)要點(diǎn)

  •  折疊是由多個(gè)塊級(jí)元素來完成的;

  • 圖片是以背景圖片的方式呈現(xiàn)出來的;

  • 給每個(gè)塊級(jí)元素設(shè)置同一張背景圖片,通過background-position來控制顯示的區(qū)域(類似于雪碧圖);

  • 通過ransform屬性來實(shí)現(xiàn)折疊效果;

  • 整個(gè)包裹div的大小就是圖片的原大小,如果更改了尺寸,需要調(diào)整background-size等屬性調(diào)整背景圖片大小

 2. 效果展示

CSS如何實(shí)現(xiàn)圖片鼠標(biāo)懸停折疊效果 

3. 源碼

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="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 {
      width: 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);
    }

    .abs {
      transform-style: preserve-3d;
      transform-origin: left center;
      transition: .4s ease-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&sec=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>

感謝各位的閱讀!關(guān)于“CSS如何實(shí)現(xiàn)圖片鼠標(biāo)懸停折疊效果”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

網(wǎng)站欄目:CSS如何實(shí)現(xiàn)圖片鼠標(biāo)懸停折疊效果
網(wǎng)站URL:http://muchs.cn/article16/jepddg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、網(wǎng)站改版、網(wǎng)站設(shè)計(jì)全網(wǎng)營(yíng)銷推廣、App開發(fā)、靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)