当前位置: 首页 > article >正文

html+css+js实现Badge 标记

实现效果:

代码实现:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Badge 标记</title>
  <link rel="stylesheet" href="./font_4689118_hfv5befzhmw/iconfont.css">
  <style>
    *{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    ul{
      list-style: none;
    }
    .source{
      margin: 50px auto;
      width: 870px;
      height: 80px;
      padding: 24px;
      border: 1px solid #ecf5ff;
    }
    .content{
      display: flex;
    }
    .content .badge{
      margin-right: 40px;
      position: relative;
    }
    .badge button{
      cursor: pointer;
      width: 55px;
      height: 30px;
      color: #606266;
      border: 1px solid #c0c4cc;
      background-color: #fff;
      border-radius: 2px;
    }
    button:hover{
      border: 1px solid rgba(64, 158, 255, 0.1);
      background-color:rgba(64, 158, 255, 0.1);
      color:#409eff ;
    }
    .badge span{
      position: absolute;
      left: 45px;
      top: -10px;
      display: inline-block;
      width: 20px;
      height: 20px;
      line-height: 20px;
      border-radius: 50%;
      font-size: 12px;
      color: #fff;
      text-align: center;
      background-color: #f56c6c;
    }
    .badge:nth-child(1) span{
      width: 35px;
      border-radius: 10px;
    }
    .badge:nth-child(3) span{
      background-color: #409eff;
    }
    .badge:nth-child(4) span{
      background-color: #e6a23c;
    }
    .dropdown{
      position: relative;
    }
    .dropdown .header{
      cursor: pointer;
      height: 30px;
      line-height: 30px;
      font-size: 14px;
      color:#409eff ;
    }
    .footer{
      position: absolute;
      right: 0;
      padding: 12px 0;
      width: 100px;
      border: 1px solid #c0c4cc;
      border-radius: 3px;
      color: #606266;
      transition: all 0.3s ease;
      transform-origin: top;
    }
    .footer li{
      height: 38px;
      line-height: 38px;
      text-align: center;
    }
    .footer li:hover{
      cursor: pointer;
      background-color:rgba(64, 158, 255, 0.1);
      color:#409eff ;
    }
    .footer li span{
      display: inline-block;
      width: 18px;
      height: 18px;
      line-height: 18px;
      border-radius: 50%;
      font-size: 12px;
      color: #fff;
      text-align: center;
      background-color: #f56c6c;
      margin-left: 5px;
    }
    .footer li:nth-child(1) span{
      width:25px;
      border-radius: 9px;
    }
    
    .footer.hide{
      transform: scaleY(0); /* Hide the footer */
    }
  </style>
</head>
<body>
  <div class="source">
    <div class="content">
      <div class="badge">
        <button>评论</button>
        <span>12</span>
      </div>
      <div class="badge">
        <button>回复</button>
        <span>3</span>
      </div>
      <div class="badge">
        <button>评论</button>
        <span>1</span>
      </div>
      <div class="badge">
        <button>回复</button>
        <span>2</span>
      </div>
      <div class="dropdown">
        <div class="header">
          <span>点我查看</span>
          <span class="iconfont icon-jiantou"></span>
        </div>
        <ul class="footer hide">
          <li>评论<span>12</span></li>
          <li>回复<span>3</span></li>
        </ul>
      </div>
    </div>
  </div>
  <script>
    document.querySelector('.dropdown .header').addEventListener('click',function(){
      const footer = this.nextElementSibling;
      footer.classList.toggle('hide')
    })
  </script>
</body>
</html>


http://www.kler.cn/news/365061.html

相关文章:

  • Python学习路线:从新手到专家
  • Python的NumPy库简介
  • 文件上传漏洞及安全
  • 1024是什么日子
  • ASP.NET Core 路由规则 MapControllerRoute、MapDefaultControllerRoute、MapController
  • 解决:如何在opencv中得到与matlab立体标定一样的矫正图?(python版opencv)
  • Mysql树形结构表-查询所有父级数据(模糊查询)
  • Android14 和android12 在锁屏界面Keyguard输错5次密码后倒计时30秒时重启手机不显示倒计时
  • SOLIDWORKS正版软件的渠道分别是哪些,如何选择?
  • 使用RNN、LSTM和Transformer进行时间序列预测
  • AJAX 实例:深入解析与实战应用
  • 代码随想录算法训练营Day09 | 151.翻转字符串里的单词、卡码网:55.右旋转字符串、28. 实现 strStr()、459.重复的子字符串
  • AUTOSAR CP 中 BswM 模块功能与使用介绍(2/2)
  • python主流框架Django:ORM框架关联查询与管理器
  • 关于Linux自带的python2.6.6升级到2.7.5版本步骤详解
  • 在银河麒麟系统中Qt连接达梦数据库
  • Python爬虫:自动化获取商品评论数据
  • 纯血鸿蒙的未来前景
  • 7款视频转换器大测评!哪款是最适合你的视频格式转换器?
  • spring boot yml文件中引用*.properties文件中的属性
  • 雷池社区版那么火,为什么站长都使用雷池社区版??
  • 我们可以用微服务创建状态机吗?
  • 边缘计算路由网关R40钡铼技术3LAN口1WAN口Modbus协议
  • 系统架构设计师教程 第6章 6.4 应用程序域数据库的交互 笔记
  • ASP.NET Core 8.0 中使用 Hangfire 调度 API
  • Python中input()输入函数和print()输出函数的用法