CSS- 横向和纵向时间轴

3 篇文章 0 订阅
2 篇文章 0 订阅

转自:https://www.cnblogs.com/xiaofeixiang/p/5036154.html

简单的实现了一下横向和纵向时间轴,可以简单的看下一下实现的效果:


Html代码:

<div class="container">
    <p>原文地址:http://www.cnblogs.com/xiaofeixiang/</p>
    <ul class="time-horizontal">
        <li><b></b>成立</li>
        <li><b></b>合作</li>
        <li><b></b>发展</li>
        <li><b></b>共赢</li>
    </ul>
</div>
<div class="container">
    <ul class="time-vertical">
        <li><b></b><span>1</span><a href="javascript:void(0)">keso</a></li>
        <li><b></b><span>2</span><a href="javascript:void(0)">FlyElephant</a></li>
        <li><b></b><span>3</span><a href="javascript:void(0)">博客园</a></li>
        <li><b></b><span>4</span><a href="javascript:void(0)">创业</a></li>
    </ul>
</div>
CSS样式:

/*横向时间轴*/
.time-horizontal {
    list-style-type: none;
    border-top: 1px solid #707070;
    max-width: 800px;
    padding: 0px;
    margin: 0px;
}
 
.time-horizontal li {
    float: left;
    position: relative;
    text-align: center;
    width: 25%;
    padding-top: 10px;
}
 
.time-horizontal li b:before {
    content: '';
    position: absolute;
    top: -10px;
    left: 47%;
    width: 12px;
    height: 12px;
    border: 2px solid #4c4c4c;
    border-radius: 8px;
    background: #4c4c4c;
}
/*纵向时间轴*/
.time-vertical {
    list-style-type: none;
    border-left: 1px solid #707070;
    padding: 0px;
    height: 400px;
}
 
.time-vertical li {
    height: 100px;
    position: relative;
}
 
.time-vertical li a {
    display: inline-block;
    margin-left: 20px;
    margin-top: 15px;
    text-decoration: none;
    color: #000;
}
 
.time-vertical li b:before {
    content: '';
    position: absolute;
    top: 15px;
    left: -12px;
    width: 18px;
    height: 18px;
    border: 2px solid #98FB98;
    border-radius: 10px;
    background: #98FB98;
}
 
.time-vertical li span {
    position: absolute;
    color: #fff;
    top: 18px;
    left: -6px;
}
关于纵向时间轴,当然我们也会遇到将线放在中间的情况,大同小异,没有差别~



  • 2
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
uni-app 本身并没有提供横向时间轴的组件,需要自己进行开发或者使用第三方组件库来实现。 一种常用的实现方式是使用 `swiper` 组件来实现横向滚动,然后在每一个滑块中放置时间轴的内容。具体实现步骤如下: 1. 使用 `swiper` 组件创建一个横向滚动视图。 ```html <swiper class="swiper" :autoplay="false" :duration="300" :circular="false" :indicator-dots="true"> <swiper-item class="swiper-item" v-for="(item, index) in timelineData" :key="index"> <!-- 这里放置时间轴的内容 --> </swiper-item> </swiper> ``` 2. 在每一个滑块中放置时间轴的内容,可以使用 `flex` 布局来实现。 ```html <view class="timeline-container"> <view class="timeline-marker"></view> <view class="timeline-content"> <view class="timeline-time">{{ item.time }}</view> <view class="timeline-text">{{ item.text }}</view> </view> </view> ``` 3. 使用 `css` 样式来实现时间轴的样式。 ```css .swiper { height: 200px; width: 100%; overflow: hidden; } .swiper-item { height: 100%; padding: 20px; } .timeline-container { display: flex; align-items: center; margin-bottom: 20px; } .timeline-marker { width: 20px; height: 20px; background-color: #333; border-radius: 50%; } .timeline-content { flex: 1; margin-left: 10px; } .timeline-time { font-size: 16px; font-weight: bold; } .timeline-text { font-size: 14px; color: #333; } ``` 这样就可以实现一个简单的横向时间轴了。当然,还可以根据具体需求来进行修改和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值