纯CSS3实现常见的时间进度线(竖立方向)

实现效果图:

实现思路:

html代码:

<div class="grow-item">
    <div class="time-line">
        <div class="time-line-dot"></div>
        <div class="time-line-title">2019年</div>
        <div class="time-line-cont">2019年厦门xxx公司被评为“国家高新技术企业”优秀奖项;</div>
    </div>
</div>
<div class="grow-item">
    <div class="time-line">
        <div class="time-line-dot"></div>
        <div class="time-line-title">2019年</div>
        <div class="time-line-cont">2019年厦门xxx公司被评为“国家高新技术企业”优秀奖项;</div>
    </div>
</div>
<div class="grow-item">
    <div class="time-line">
        <div class="time-line-dot"></div>
        <div class="time-line-title">2019年</div>
        <div class="time-line-cont">2019年厦门xxx公司被评为“国家高新技术企业”优秀奖项;</div>
    </div>
</div>

css代码:

.grow-item {display: flex;justify-content: space-between;height: 180px;}

.grow-item .time-line {position: relative;height: auto;padding:59px 146px 0 38px; border-left: 1px solid #e5e6e9;}

.grow-item:last-child .time-line:after {content: '';position: absolute;bottom: 0;left: -7px;width: 14px;height: 17px;border-radius: 5px;background-color: #e5e6e9;transform: perspective(4px) rotateX(12deg);}

.grow-item .time-line .time-line-dot {position: absolute;left: -10px; width: 18px;height: 18px;background-color: #ffffff;border-radius: 50%;border: solid 1px #d2d3d4;}

.grow-item .time-line .time-line-dot::after {content: ''; position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%); width: 10px;height: 10px;border-radius: 50%; background-color: #f49f16;}

.grow-item .time-line .time-line-title {font-size: 20px;font-weight: bold;color: #171f31;line-height: 23px;}

.grow-item .time-line .time-line-cont {font-size: 14px;color: #353f57;line-height: 24px;margin-top: 10px;}

 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
可以使用CSS3中的transform和animation属性来实现圆环百分比进度的效果,具体步骤如下: 1. 创建一个圆环的基本样式,设置圆环的宽度、颜色和边框样式: ``` .progress { width: 100px; height: 100px; border: 10px solid #eee; border-radius: 50%; position: relative; } .progress:before { content: ""; width: 100%; height: 100%; border-radius: 50%; border: 10px solid #ccc; position: absolute; top: 0; left: 0; } ``` 2. 使用transform属性将圆环旋转90度,使起点从顶部开始: ``` .progress:before { transform: rotate(-90deg); } ``` 3. 使用animation属性设置动画效果,将圆环的进度从0%到指定百分比: ``` .progress:after { content: ""; width: 100%; height: 100%; border-radius: 50%; border: 10px solid #000; position: absolute; top: 0; left: 0; transform: rotate(-90deg); animation: progress 2s ease-out forwards; } @keyframes progress { from { transform: rotate(-90deg); } to { transform: rotate(calc(-90deg + (360 * 80 / 100))); } } ``` 其中,animation属性中的forwards参数表示动画结束后保持最后一帧状态,calc函数用来计算旋转角度。 4. 在HTML中添加进度条的容器,并设置对应的百分比: ``` <div class="progress" data-progress="80"></div> ``` 5. 使用JavaScript获取进度条容器和其对应的百分比,将百分比值设置为圆环的进度: ``` const progress = document.querySelector('.progress'); const percent = progress.getAttribute('data-progress'); progress.style.setProperty('--progress', `${percent}%`); ``` 6. 最后,在CSS中使用var函数获取JavaScript设置的进度值,并将其应用到圆环的进度样式中: ``` .progress:after { transform: rotate(calc(-90deg + (360 * var(--progress) / 100))); } ``` 这样就可以实现一个简单的圆环百分比进度条。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宋承佑

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值