自适应动画的步骤条CSS3

在这里插入图片描述

<template>
	<view class="step_box">
		<view class="top" style="margin-bottom: 20rpx">
			<text class="item" v-for="(item,index) in list" :key="index">{{item.label}}</text>
		</view>
		<view class="progress">
			<view class="dot_box" :class="{active: handleIndex(index)}" v-for="(item,index) in list" :key="index">
				<view class="dot" :class="{active: current >= index}">

				</view>
			</view>

		</view>
		<view class="top">
			<text class="item" v-for="(item,index) in list" :key="index">{{item.text}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		name: "steps",
		props: {
			current: {

				type: Number | String,
				default: 0

			}
		},
		data() {
			return {
				list: [{
					text: '打开空仓',
					label: '第一步'
				}, {
					text: '归还旧电池',
					label: '第二步'
				}, {
					text: '更新新电池',
					label: '第三步'
				}, {
					text: '完成换电',
					label: '第四步'
				}]
			};
		},
		methods: {
			handleIndex(i) {

				let cur = this.current
				return cur === 0 ? false : cur - 1 >= i;

			}
		}
	}
</script>

<style lang="scss" scoped>
	.step_box {
		width: 100%;
		padding: 40rpx 0;

		.progress {
			margin-bottom: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-around;
			width: 100%;

			.dot_box {
				flex: 1;
				display: flex;
				align-items: center;
				justify-content: center;
				position: relative;


			&:not(:last-child)::after {
				content: '';
				width: 100%;
				height: 16rpx;
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				left: calc(50% - 15rpx);
				background-color: #D8D8D8;
				z-index: 0;
			}
			
			&:first-child::after {
				content: '';
				width: 100%;
				height: 16rpx;
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				left: calc(50% - 15rpx);
				background-color: #D8D8D8;
			}
				
				&:not(:last-child)::before {
					content: '';
					width: 0%;
					height: 16rpx;
					position: absolute;
					top: 50%;
					transform: translateY(-50%);
					left: calc(50% - 15rpx);
					// background-color: #D8D8D8;
					z-index: 1;
					transition: .5s;
				}
				
				

				
			
				&.active {
					&::before {
            width:100%;
						background-color: #37AA4A;
					}
					
				}
				
				

				.dot {
					width: 38rpx;
					height: 38rpx;
					border-radius: 92px;
					background: #D8D8D8;
					position: relative;
					z-index: 4;




					&.active {
						transition-delay: 0.5s;
						background: #37AA4A;
					}
				}
			}

		}

		.top {

			display: flex;
			align-items: center;
			justify-content: space-around;

			.item {
				font-family: Source Han Sans;
				font-size: 32rpx;
				font-weight: bold;
				line-height: normal;
				letter-spacing: 0em;

				font-feature-settings: "kern" on;
				color: #3D3D3D;
			}
		}
	}
</style>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

ゎ - 久然゜

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

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

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

打赏作者

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

抵扣说明:

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

余额充值