基于vue框架怎样实现水平时间轴,思路及方法是什么
Admin 2022-06-22 群英技术资讯 1486 次浏览
这篇文章给大家分享的是“基于vue框架怎样实现水平时间轴,思路及方法是什么”,对大家学习和理解有一定的参考价值和帮助,有这方面学习需要的朋友,接下来就跟随小编一起学习一下吧。
先上图,主要实现两列水平时间轴,查看了很多人实现的,水平只有一列,并且elementUI的时间轴只有竖着的,不支持横向,最后只能含泪自己实现了,没想到还可以,只是如果数据很多翻页还没实现,有实现过这种的掘友可以艾特我一下。
timelineH.vue中的H代表横,起名字烦恼,哈哈。
<template>
<ul class="timelineHengBox">
<li class="timelineHengItem" v-for="(item,index) in timelineList" :key="index"
:style="{left: index % 2 != 0 ? (liHalf*index)+52+'px':0,'border-right': index == timelineList.length - 2 ?'1px solid #FEFEFE' : 'none'}">
<div class="timeline_dot" :style="{top: index % 2 != 0 ? '-5px' : '93px'}"></div>
<div class="timeline_dot" v-show="index == timelineList.length - 2" style="right: -6px;top:93px;left: unset;"></div>
<div class="timeline_wapper flex" :class="{'mt20': index % 2 != 0}">
<img src="../../static/img/excelIcon.png" class="bjIcon" :style="{'margin': index % 2 != 0 ? '11px 44px 0 42px' :''}">
<div>{{item.content}}</div>
</div>
<div class="timelineDate_bottom" :style="{'top': index % 2 != 0 ? '-20px' : '103px'}">{{item.dateTime}}</div>
</li>
</ul>
</template>
<script>
export default {
name: 'timelineH',
props: {
timelineList: {
type: Array,
default: []
}
},
data () {
return {
liWidth: 496,//整个li的宽度,要和下面的li样式统一
liHalf: 248,//这里是li一半的宽度,使中间横线上的点可以找到准确的位置
}
}
}
</script>
<style scoped>
.timelineHengBox {
color: #fff;
margin: 0;
padding: 0 26px;
width: 92%;
padding-top: 18px;
padding-bottom: 10px;
margin-left: 26px;
height: 87px;
border-bottom: 3px solid #FEFEFE;
}
.timelineHengItem {
list-style: none;
height: 97px;
width: 496px;
border-left: 1px solid #FEFEFE;
float: left;
border-bottom: 3px solid #FEFEFE;
position: relative;
}
.timelineHengItem:nth-child(2n) {
position: absolute;
left: 248px;
border-bottom: 0;
top: 115px;
}
.timeline_dot {
width: 10px;
height: 11px;
background: #FEFEFE;
position: absolute;
left: -5px;
top: 93px;
}
.timeline_dot:nth-child(2n) {
top: -7px;
}
.timeline_wapper {
width: 400px;
text-align: left;
font-size: 12px;
color: #FFFFFF;
line-height: 20px;
}
.mt20 {
margin-top: 20px;
}
.bjIcon {
width: 32px;
height: 32px;
margin: 31px 44px 0 42px;
}
.timelineDate_bottom {
width: 80px;
height: 20px;
position: absolute;
top: 103px;
left: -60px;
text-align: left;
font-size: 14px;
font-weight: bold;
color: #FFBA00;
margin-left: 77px;
}
</style>
实现思路:
<div class="timelineHengContainer">
<timelineH :timelineList='timelineList' />
</div>
js:
import timelineH from "@/components/timelineH.vue";
components: {
timelineH
},
data() {
return {
timelineList: [
{
dateTime: '2021-09',
content: '欢迎挖矿,天天挖矿,得到矿石,哈哈哈,欢迎挖矿,天天挖矿,得到矿石,哈哈哈,欢迎挖矿,天天挖矿,得到矿石,哈哈哈,欢迎挖矿,天天挖矿,得到矿石,哈哈哈。'
},{
dateTime: '2021-10',
content: '冬天要注意保暖,太冷了呢,冬天要注意保暖,太冷了呢,冬天要注意保暖,太冷了呢,冬天要注意保暖,太冷了呢。'
},{
dateTime: '2021-11',
content: '更文挑战三十天正式开始啦,我想要投影仪,一直想买的。'
},{
dateTime: '2021-12',
content: '就要到月底啦,新的一年开始,新年快乐,新的一年开始,新年快乐,新的一年开始,新年快乐。'
}
]
}
}
css:
.timelineHengContainer {
width: 100%;
height: 227px;
background-image: url('../../static/img/timelineBg.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
好啦,这就实现了水平两列的时间轴了,可以把代码复制下来直接用(使用CV大法吧~)。当时弄了两天,参考了elementui的纵向时间轴的画法,没有做出来,又用纯div和css实现也没有成功,主要是两列的竖线不知道该怎么画,还有节点,最后想起用li直接加个边框实现。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
nodejs中想要访问根目录同级目录里的文件,开始用__dirname,发现_dirname只是追加自身的目录路径,能调取到同级目录下的文件,却不能调取其他目录下的文件,尝试把文件路径换成相对路径可以访问成功,考虑到项目中不会去层层翻目录,翻了资料nodejs的fs模块大多是结合了nodejs的path模块使用,path.resolve和path.join两个方法能传入文件路径,并且文件不存在时会
今天我们来了解一下JS数组reduce方法的使用,在Javascript数组方法中,一般大家使用的迭代方法有map、filter、forEach等这些,其实reduce方法也很好用,下面我们就来详细的了解看看reduce()方法。
轮播图是现在很多网站平台都会应用的一种展现方式,通过定时或者鼠标点击就能够切换看到多张图片,很多商都会将轮播图作为产品展示,这样的效果是用户就能更容易获取商品信息。那么轮播图是如何实现的呢?下面就以基于JavaScript实现的简单轮播图为例,为大家简单介绍下。
缓动动画原理:移动的像素慢慢减少,让效果看起来更柔和更美观,通过定时器加回调函数,实现动画效果以及更多具体功能,非常好用
这篇文章主要介绍了JavaScript设计模式之职责链模式,对设计模式感兴趣的同学,可以参考下
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008