如下,最近在工作中遇到实现时间线效果的需求,用纯css即可实现,下面给出详细实现代码。

  

html:

 <div class="time_line_list_wrap hide">
<ul class="time_line">
<li>
<div class="time_line_item_wrap">
<span class="time">00:00:00</span>
</div>
</li>
<li class="time_line_item_tmpl">
<div class="time_line_item_wrap">
<span class="time"></span>
<div class="time_item_contain_wrap">
<img class="ppt_item_img_left">
<div class="item_contain_right">
<p class="ppt_name">中文课件名称超过了一定长度的字之后隐藏</p>
<span class="item_page_number">2/30</span>
</div>
</div>
</div>
</li>
</ul>
</div>

css:(此处用的less语法)

 .time_line_list_wrap{
width: 100%;
height: 100%;
overflow-y: scroll;
overflow-x: hidden;
background-color: #ffffff;
padding:;
flex-grow:; .time_line{
padding: 16px 10px 0px 10px;
li{
list-style-type: none;
position: relative;
width: 2px;
height: 102px;
background-color: #e6e6e6; &.time_line_item_tmpl{
display: none;
} &:last-child{
height: 0px;
} &:first-child{
height: 30px;
} &:before{
content: '';
position: absolute;
left: 50%;
top:;
transform: translateX(-50%);
width: 8px;
height: 8px;
border-radius: 50%;
background: inherit;
} .time_line_item_wrap {
width: 280px;
margin-left: 10px;
position: relative;
bottom: 6px; &:last-child{
margin-bottom: 20px;
} &:first-child{
margin-bottom: 0px;
} .time{
display: inline-block;
width: 92px;
height: 20px;
line-height: 20px;
font-size: 12px;
color: #4a90e2;
box-sizing: border-box;
padding-left: 10px;
}
.time_item_contain_wrap{
display: flex;
padding: 10px 0 10px 9px; .ppt_item_img_left{
width: 80px;
height: 62px;
object-fit: contain;
flex-shrink:;
} .item_contain_right{
font-size: 12px;
color: #696969;
font-weight:;
margin-left: 8px;
width: 68%; .ppt_name{
.text-autocut();
}
}
}
}
}
} &.hide{
display: none;
}
}

js:

 const $timeLineUl = $('.time_line')
const $timeLineItemTmpl = $('.time_line_item_tmpl').clone().removeClass('time_line_item_tmpl') // 初始化侧边栏中时间线数据
for (let i = 0; i < slideInfo.length; i += 1) {
const currentSlide = slideInfo[i]
const $timeLineItem = $timeLineItemTmpl.clone()
$timeLineItem.find('.time').text(formatTime(currentSlide.recordTime / 1000).join(':'))
$timeLineItem.find('.time').css({
background: `url(${triangleTimeStr}) no-repeat center`,
})
$timeLineItem.find('.ppt_item_img_left').attr('src', currentSlide.slideUrl)
$timeLineItem.find('.ppt_name').text(currentSlide.slideName)
$timeLineItem.find('.item_page_number').text(`${currentSlide.currentPageNumber}/${currentSlide.totalPageNumber}`)
$timeLineUl.append($timeLineItem)
}

注意此处,需要用find()方法来查找后代元素,.children()方法是查找直接后代(儿子辈)的元素,.find()方法是查找所有后代元素(包括儿子、孙子、孙子的孙子及更多)。

CSS之实现垂直时间线展示相关内容效果的更多相关文章

  1. 一款纯css实现的垂直时间线效果

    今天给大家分享一款纯css实现的垂直时间线效果.垂直时间线适合放在类似任务时间安排的网页上.该实现采用了蓝色作为主题色,界面效果还不错.一起看下效果图: 实现的代码. html代码: ... 阅读原文 ...

  2. 纯css实现同一页面下选择之后更换内容效果

    实现效果为如下:在同一页面下,当我选中输入手机号时,出现手机号输入框,当我选中输入验证码时,出现验证码输入框,当我选中设置密码时,出现密码框 在这里有一个小技巧,就是  1.对下面的输入框设置同样的样 ...

  3. 腾讯微博API时间线相关接口返回的微博信息中head值使用问题

    腾讯微博API时间线相关接口返回的微博信息中head值表示作者头像url,这个链接直接访问并不能使用,需要再附加一个参数指定图片的大小(100.50),比如:[head]/100.

  4. moviepy音视频剪辑:与time时间线相关的变换函数freeze_region、make_loopable、speedx、time_mirror、time_symmetrize介绍

    ☞ ░ 前往老猿Python博文目录 ░ 一.引言 在<moviepy音视频剪辑:moviepy中的剪辑基类Clip详解>介绍了剪辑基类的fl.fl_time.fx方法,在<movi ...

  5. echarts的时间线图表

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...

  6. Layui选项卡、进度条、面板、徽章、时间线、辅助元素

    Layui选项卡.进度条.面板.徽章.时间线.辅助元素 Tab选项卡 - 页面元素    导航菜单可应用于头部和侧边,Tab选项卡提供多套风格,支持响应式,支持删除选项卡等功能.面包屑结构简单,支持自 ...

  7. 《时间线》:WWT 数字宇宙,虚拟星空

    李北辰/文 王尔德说:我们生活在阴沟里,却仍有人仰望星空.如今,这句感叹依旧代表某种程度的正确,但这位19世纪的英国绅士有所不知:在一百多年后的东方"帝都",当困于阴沟中的年轻人们 ...

  8. WPF中的动画——(三)时间线(TimeLine)

    WPF中的动画——(三)时间线(TimeLine) 时间线(TimeLine)表示时间段. 它提供的属性可以让控制该时间段的长度.开始时间.重复次数.该时间段内时间进度的快慢等等.在WPF中内置了如下 ...

  9. 如何解决Angular网页内嵌推特时间线无法正常显示

    我最近解决了一个折磨了我好久但是解决方法却只是添加两三行代码的问题.我没有在网上找到合适的解决方案,最后是我根据官方网站和很多的帖子里的部分代码得到的启发,尝试了很久之后得到的解决方法.因为过程实在是 ...

随机推荐

  1. spring boot集成redis实现session共享

    1.pom文件依赖 <!--spring boot 与redis应用基本环境配置 --> <dependency> <groupId>org.springframe ...

  2. session 和 cookie

    在web请求中,很多的时候服务器需要知道来访的客户是谁,但是HTTP协议本身是不带认证的(ftp协议需要用户密码),因此cookie和session诞生了.   session是解决http协议无状态 ...

  3. docker实战---初级<1>

    第1章 docker容器 1.1 什么是容器 容器就是在隔离的环境运行的一个进程,如果进程停止,容器就会销毁.隔离的环境拥有自己的文件系统,ip地址,主机名等 1.2 容器与虚拟化的区别 linux容 ...

  4. 删除打开方式里的wine

    title: "删除打开方式里的wine" date: 2018-05-27T13:54:28+08:00 tags: ["wine"] categories: ...

  5. day20 python常用模块

    认识模块 什么是模块? 常见的场景:一个模块就是一个包含了python定义和声明的文件,文件名就是模块名字加上.py的后缀.     但其实import加载的模块分为四个通用类别: 1 使用pytho ...

  6. 【论文速读】Fangfang Wang_CVPR2018_Geometry-Aware Scene Text Detection With Instance Transformation Network

    Han Hu--[ICCV2017]WordSup_Exploiting Word Annotations for Character based Text Detection 作者和代码 caffe ...

  7. java基础语法-内部类与匿名内部类

    1.成员内部类(声明在类内部&&方法之外) class Person{ String name = "韩梅梅"; int age; class Bird{ Stri ...

  8. 1.字符串操作:& 2.英文词频统计预处理

    1.字符串操作: 解析身份证号:生日.性别.出生地等. ID = input('请输入十八位身份证号码: ') if len(ID) == 18: print("你的身份证号码是 " ...

  9. css img 隐藏的边距

    因为图片存在浏览器默认的边距,正常的情况下,增加这样的属性来消除多余的边距或者多1px的情况 img { display: block; border: node; } 但是这样的话img在父元素里设 ...

  10. go区块链学习教程之iris框架mvc架构

    在Iris框架中,封装了mvc包作为对mvc架构的支持,方便开发者遵循mvc的开发原则进行开发. iris框架支持请求数据.模型.持久数据分层处理,并支持各层级模块代码绑定执行. MVC即:model ...