惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MongoDB | Blog
MongoDB | Blog
B
Blog
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
博客园 - Franky
V
V2EX
IT之家
IT之家
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
F
Fortinet All Blogs
I
InfoQ
云风的 BLOG
云风的 BLOG
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog

牛牛技术客栈

设计模式-备忘录模式 - OXOXTECH 牛牛技术客栈 设计模式-中介者模式 - OXOXTECH 牛牛技术客栈 Linux【Ubuntu】修改ssh默认端口 - OXOXTECH 牛牛技术客栈 设计模式-迭代器模式 - OXOXTECH 牛牛技术客栈 scheduled定时任务的三种基本实现方式 - OXOXTECH 牛牛技术客栈 Apriori - 基于关联规则的推荐算法(三) - OXOXTECH 牛牛技术客栈 Apriori - 基于关联规则的推荐算法(二) - OXOXTECH 牛牛技术客栈 Apriori - 基于关联规则的推荐算法(一) - OXOXTECH 牛牛技术客栈 基于JavaFX的桌面端网络调试工具 - OXOXTECH 牛牛技术客栈 Golang Channel的原理介绍 - OXOXTECH 牛牛技术客栈 Go语言Map的原理分析 - OXOXTECH 牛牛技术客栈 Go语言错误处理(panic)的最佳实践 - OXOXTECH 牛牛技术客栈 设计模式-解释器模式 - OXOXTECH 牛牛技术客栈 Redis报错Redis is configured to save RDB snapshots, but it's currently unable to persist to disk. go-webpbin库在Linux报错failed to encode image to WebP: exit status 1.......的问题 exe4j 打包加密的jar - OXOXTECH 牛牛技术客栈 Go生成图形验证码示例 - OXOXTECH 牛牛技术客栈 澳门一天游:一日尽享东方与西方的交融之美 - OXOXTECH 牛牛技术客栈 设计模式-命令模式 - OXOXTECH 牛牛技术客栈 别再自己瞎写工具类了,SpringBoot内置工具类应有尽有 - OXOXTECH 牛牛技术客栈 中山一日游 - OXOXTECH 牛牛技术客栈 设计模式-责任链模式 - OXOXTECH 牛牛技术客栈 起舞吧,齐舞吧 - OXOXTECH 牛牛技术客栈 设计模式-组合模式 - OXOXTECH 牛牛技术客栈 Go语言Web开发|GoFrame框架入门笔记 - OXOXTECH 牛牛技术客栈 Java打包exe教程 - OXOXTECH 牛牛技术客栈 设计模式-代理模式 - OXOXTECH 牛牛技术客栈 MySQL存储过程的优缺点有哪些? - OXOXTECH 牛牛技术客栈 前端渲染优化有哪些? - OXOXTECH 牛牛技术客栈 HTTP状态码及其含义 - OXOXTECH 牛牛技术客栈
CSS实现从下至上弹出的抽屉动画 - OXOXTECH 牛牛技术客栈
Mr.Potato · 2023-01-17 · via 牛牛技术客栈

Mr.Potato 前端 CSS

从下至上展开抽屉动画

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <title></title>
  <style>
    .container {
      margin: auto;
      top: 460px;
      width: 320px;
      height: 30px;
      position: relative;
      background-color: rgba(0, 0, 0, 0.4);
      overflow-y: auto;
      scroll-behavior: smooth;
      border-radius: 20px;
    }

    /* 隐藏滚动条 */
    ::-webkit-scrollbar {
      display: none;
    }

    .expend {
      animation: expend ease 1s forwards;
    }

    .close-container {
      animation: no-expend ease 1s forwards;
    }

    @keyframes expend {
      from {
        top: 460px;
        height: 30px;
      }

      to {
        height: 330px;
        top: 160px;
      }
    }

    @keyframes no-expend {
      from {
        height: 330px;
        top: 160px;
      }

      to {
        top: 460px;
        height: 30px;
      }
    }

    .close {
      color: aliceblue;
      right: 0;
      margin: 5px 10px;
      position: absolute;
    }

    .title {
      color: aliceblue;
      height: 30px;
      line-height: 30px;
      margin: 0 10px;
      position: absolute;
    }

    .list {
      display: flex;
      /* 子元素换行 */
      flex-wrap: wrap;
      white-space: nowrap;
      padding-top: 24px;
    }

    .item {
      width: 80px;
      height: 80px;
      margin: 40px;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: center;
    }

    .item-img {
      width: 40px;
      height: 40px;
    }
  </style>
</head>

<body>

  <div class='container' id='container'>
    <div class='title'>抽屉标题</div>
    <div class='close' onclick='closeHandle()'>↑</div>
    <div class='list'>
      <div class='item'>
        <img src="./Icon_template.png" class="item-img">
        <span class='item-text'>内容1</span>
      </div>
      <div class='item'>
        <img src="./Icon_template.png" class="item-img">
        <span class='item-text'>内容2</span>
      </div>
      <div class='item'>
        <img src="./Icon_template.png" class="item-img">
        <span class='item-text'>内容3</span>
      </div>
      <div class='item'>
        <img src="./Icon_template.png" class="item-img">
        <span class='item-text'>内容4</span>
      </div>
      <div class='item'>
        <img src="./Icon_template.png" class="item-img">
        <span class='item-text'>内容4</span>
      </div>
    </div>
  </div>

  <script>
    const closeHandle = () => {
      console.log('关闭和展开');
      const dom = document.getElementById('container');
      const closeDom = document.getElementsByClassName('close')[0];
      if (!dom.className.match(/(?:^|\s)expend(?!\S)/)) {
        dom.className = "container expend";
        setTimeout(() => {
          closeDom.innerText = 'X'
        }, 100)
      } else {
        dom.className = "container close-container";
        setTimeout(() => {
          closeDom.innerText = '↑'
        }, 100)
      }
    }
  </script>
</body>
</html>