CSS之实现垂直时间线展示相关内容效果
如下,最近在工作中遇到实现时间线效果的需求,用纯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之实现垂直时间线展示相关内容效果的更多相关文章
- 一款纯css实现的垂直时间线效果
今天给大家分享一款纯css实现的垂直时间线效果.垂直时间线适合放在类似任务时间安排的网页上.该实现采用了蓝色作为主题色,界面效果还不错.一起看下效果图: 实现的代码. html代码: ... 阅读原文 ...
- 纯css实现同一页面下选择之后更换内容效果
实现效果为如下:在同一页面下,当我选中输入手机号时,出现手机号输入框,当我选中输入验证码时,出现验证码输入框,当我选中设置密码时,出现密码框 在这里有一个小技巧,就是 1.对下面的输入框设置同样的样 ...
- 腾讯微博API时间线相关接口返回的微博信息中head值使用问题
腾讯微博API时间线相关接口返回的微博信息中head值表示作者头像url,这个链接直接访问并不能使用,需要再附加一个参数指定图片的大小(100.50),比如:[head]/100.
- moviepy音视频剪辑:与time时间线相关的变换函数freeze_region、make_loopable、speedx、time_mirror、time_symmetrize介绍
☞ ░ 前往老猿Python博文目录 ░ 一.引言 在<moviepy音视频剪辑:moviepy中的剪辑基类Clip详解>介绍了剪辑基类的fl.fl_time.fx方法,在<movi ...
- echarts的时间线图表
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...
- Layui选项卡、进度条、面板、徽章、时间线、辅助元素
Layui选项卡.进度条.面板.徽章.时间线.辅助元素 Tab选项卡 - 页面元素 导航菜单可应用于头部和侧边,Tab选项卡提供多套风格,支持响应式,支持删除选项卡等功能.面包屑结构简单,支持自 ...
- 《时间线》:WWT 数字宇宙,虚拟星空
李北辰/文 王尔德说:我们生活在阴沟里,却仍有人仰望星空.如今,这句感叹依旧代表某种程度的正确,但这位19世纪的英国绅士有所不知:在一百多年后的东方"帝都",当困于阴沟中的年轻人们 ...
- WPF中的动画——(三)时间线(TimeLine)
WPF中的动画——(三)时间线(TimeLine) 时间线(TimeLine)表示时间段. 它提供的属性可以让控制该时间段的长度.开始时间.重复次数.该时间段内时间进度的快慢等等.在WPF中内置了如下 ...
- 如何解决Angular网页内嵌推特时间线无法正常显示
我最近解决了一个折磨了我好久但是解决方法却只是添加两三行代码的问题.我没有在网上找到合适的解决方案,最后是我根据官方网站和很多的帖子里的部分代码得到的启发,尝试了很久之后得到的解决方法.因为过程实在是 ...
随机推荐
- ESP8266 RTOS SDK编译环境搭建
前提条件 1. linux操作系统或者windows下的linux虚拟机或者OS X操作系统 2. 联网 下载 * [Mac](https://dl.espressif.com/dl/xtensa-l ...
- 谷歌AM HTML视频代码amp-video示例
ntroduction Use amp-video to embed videos into your AMP HTML files. Video source files must be serve ...
- Ubuntu设置su和sudo为不需要密码 (摘录自别处)
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/langb2014/article/details/54646675 针对非服务器用户,只是用普通的U ...
- Cocos Creator 生命周期回调(官方文档摘录)
Cocos Creator 为组件脚本提供了生命周期的回调函数.用户通过定义特定的函数回调在特定的时期编写相关 脚本.目前提供给用户的声明周期回调函数有: onLoad start update la ...
- Vuex 2.0 深入简出
最近面试充斥了流行框架Vue的各种问题,其中Vuex的使用就相当有吸引力.下面我就将自己深入简出的心得记录如下: 1.在vue-init webpack project (创建vue项目) 2.src ...
- java 自动拆箱
Integer a0 = ; Integer a1 = ; Integer b0 = ; Integer b1 = ; ; System.out.println(a0 == a1); >> ...
- Kindle:自动追更之Calibre2脚本
#!/usr/bin/env python2 # vim:fileencoding=utf-8 from __future__ import unicode_literals, division, a ...
- Wireshark使用介绍(一):Wireshark基本用法
抓取报文: 下载和安装好Wireshark之后,启动Wireshark并且在接口列表中选择接口名,然后开始在此接口上抓包.例如,如果想要在无线网络上抓取流量,点击无线接口.点击Capture Opti ...
- ajax的网上解析
/* 用XMLHTTPRequest来进行ajax异步数据交交互*/ 主要有几个步骤: //1.创建XMLHTTPRequest对象 //最复杂的一步 if (window.XMLHttpReques ...
- python 名称前的单下划线
单前导下划线 _var 1.特点一 在PEP8约定中定义,以单个下划线开头的变量或方法仅供内部使用.用于指定该名称属性为“私有”.为了使其他人(或你自己)使用这些代码时将会知道以“_”开头的名称只供内 ...