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网页内嵌推特时间线无法正常显示
我最近解决了一个折磨了我好久但是解决方法却只是添加两三行代码的问题.我没有在网上找到合适的解决方案,最后是我根据官方网站和很多的帖子里的部分代码得到的启发,尝试了很久之后得到的解决方法.因为过程实在是 ...
随机推荐
- 【MySQL】sort by then group by
tb: ### 需求:根据id进行分组,找到分组内hour中最大的一项 错误写法: select id, max(hour) from tb group by id; 正确的写法: ### 需求:根据 ...
- Kafka笔记7(构建数据管道)
构建数据管道需要考虑的问题: 及时性 可靠性 高吞吐量和动态吞吐量 数据格式 转换 安全性 故障处理能力 耦合性与灵活性 数据管道的构建分为2个阵营,ETL和ELT ETL:提取- ...
- MFC消息 OnCtlColor 改变控件颜色
OnCtlColor 有以下几个宏定义 #define CTLCOLOR_MSGBOX 0 #define CTLCOLOR_EDIT 1 #defin ...
- eslint的安装与使用
什么是 ESLint ESLint(中文站点)是一个开源的 JavaScript 代码检查工具,使用 Node.js 编写,由 Nicholas C. Zakas 于 2013 年 6 月创建.ESL ...
- cycle标签和random两种方式美化表格
一:cycle标签实现给表格变色 1. <style>标签里写好需要的颜色 2. 在要变色的地方(行/列)加固定的语句,按照顺序依次执行 代码: <!DOCTYPE html> ...
- js点击出现二级菜单,点击二级菜单主菜单换成二级菜单
点击出现二级菜单 *{ margin:0px auto; padding:0px; } .yiji{ width:200px; height:40px; background-color:red; c ...
- Kendo DropDownListFor值传不回去的小坑
做项目时,在KendoWindow弹框里面写了个表单提交,不小心把AreaId 下拉框设置了Name为“OrderAreaId”.在后台接收不到AreaId的参数.后来才发现是Name的设置强行把A ...
- [python 练习] 计算个税
题目:利用python计算个税 说明:python有序字典的使用 代码: # -*- coding: utf-8 -*- from collections import OrderedDict # 税 ...
- koa2:通过Ajax方式上传文件,使用FormData进行Ajax请求
koa2通过表单上传的网上很多,但通过Ajax方式上传文件,使用FormData进行Ajax请求,不好找. 参考了这个用base64上传图片的例子.https://github.com/Yuki-Mi ...
- 判断是否为JSON对象
$.ajax({ type: 'POST', url: url, success(function(data){ //判断是否为JSON对象 if(typeof(data) == "obje ...