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

用尽可能简单易懂的代码做个时间轴(时间线)

用尽可能简单的代码,做个时间线或者时间轴展示功能,效果如图:

特点:纯DIV+CSS构建,需要展示到什么进度,直接加active属性就行了。

还贴心给配了个setProgress(step)函数,功能太简单,没必要封装了。

到最后,jQuery也懒得用了。

上代码:

<!DOCTYPE html>
<html><head><meta charset="utf-8" ><title>time line</title></head><body><!-- 合肥向阳互联文化传媒有限公司 --><style>/* active颜色:#1890ff */.container-progressline{width: 70%; margin: 0 auto; font-size:12px; color: #333;}.progress-item{width:25%; height: 70px; background: #fff; position: relative; float: left;}.progress-line{height: 4px; width: 100%; background: #ddd; border:none; width:100%; position: absolute; top: 33px;}.container-progressline::after{content: " "; display: block; height: 0; width: 0; visibility: hidden; clear: both;}.progress-datetime{position:absolute; top: 11px; width: 100%; text-align: center;}.progress-title{position:absolute; bottom: 11px; width: 100%; text-align: center;}.progress-point{position: absolute; top: 27px; left: 45%; height: 10px; width: 10px; border-radius: 50%; z-index: 1; background: #ddd; border: 3px #fff solid;}.progress-item.active .progress-line{background: #1890ff;}.progress-item.active .progress-point{background: #1890ff;}</style><div class="container-progressline"><div class="progress-item active"><div class="progress-line"></div><div class="progress-point"></div><div class="progress-datetime">2023-12-31 00:00:00</div><div class="progress-title">这是这个节点的标题</div></div><div class="progress-item"><div class="progress-line"></div><div class="progress-point"></div><div class="progress-datetime">2023-12-31 00:00:00</div><div class="progress-title">这是这个节点的标题</div></div><div class="progress-item"><div class="progress-line"></div><div class="progress-point"></div><div class="progress-datetime">2023-12-31 00:00:00</div><div class="progress-title">这是这个节点的标题</div></div><div class="progress-item"><div class="progress-line"></div><div class="progress-point"></div><div class="progress-datetime">2023-12-31 00:00:00</div><div class="progress-title">这是这个节点的标题</div></div></div><script>/*** 设置进度*/function setProgress(step){var item;classes = document.getElementsByClassName('progress-item');if(step > classes.length){var strErr = '函数参数设置的步骤大于实际的步骤条目!';console.error(strErr);alert(strErr);return;}for(i = 0; i < classes.length; ++i){classes[i].classList.remove('active');//删除类名}for(i = 0; i < step; ++i){classes[i].classList.add('active');}}setProgress(3);</script></body>
</html>

http://www.lryc.cn/news/224240.html

相关文章:

  • STM32笔记—定时器
  • 【力扣:1504】统计全1子矩阵
  • 排序算法之-选择
  • 机器学习模板代码(期末考试复习)自用存档
  • 使用sizeof()和strlen()去计算【数组】和【指针】的大小
  • viple进阶4:打印空心三角形
  • Oauth2.0的内容
  • npm 下载包失败解决方案
  • C语言---插入排序、希尔排序、冒泡排序、选择排序、快速排序简单介绍
  • 撸视频号收益这个副业靠谱吗?
  • 2、数组、Map+HashMap、Set+Hashset、Char和Character类、String类和Char类、Math类
  • ESP8266 WiFi模块快速入门指南
  • 微信小程序将后端返回的图片文件流解析显示到页面
  • 网络基础(1)
  • flink的AggregateFunction,merge方法作用范围
  • Day25力扣打卡
  • SpringCloud - OpenFeign 参数传递和响应处理(全网最详细)
  • Postgresql数据类型-布尔类型
  • SPASS-交叉表分析
  • 用Python的requests库来模拟爬取地图商铺信息
  • 使用EvoMap/Three.js模拟无人机灯光秀
  • 11.9存储器实验总结(单ram,双ram,FIFO)
  • linux(ubuntu)安装并使用scrcpy
  • linux rsyslog安装配置
  • 美国Embarcadero公司正式发布2023 RAD Studio Delphi C++ Builder 12 Athens
  • 树莓派4B的测试记录(CPU、FFMPEG)
  • 物联网AI MicroPython学习之语法 二进制与ASCII转换
  • 学之思项目的搭建部署 打jar包失败的解决方法
  • [100天算法】-定长子串中元音的最大数目(day 67)
  • Elastic Observability 8.11:ES|QL、APM 中的通用分析和增强的 SLOs