css样式

 

 

 

<template>
	<view>
		<view class="line_box">
			<view class="line_con left" :style="{background: backBg}">
				<text class="txt left_out" v-if="leftNum <= 25">{{ leftTexts }}</text>
				<view class="line" :style="{'background': leftBg, 'width': leftNum + '%'}">
					<text class="txt" v-if="leftNum > 25">{{ leftTexts }}</text>
				</view>
			</view>
			<view class="line_con right" :style="{background: backBg}">
				<view class="line" :style="{'background': rightBg, 'width': rightNum + '%'}">
					<text class="txt" v-if="rightNum > 25">{{ rightTexts }}</text>
				</view>
				<text class="txt right_out" v-if="rightNum <= 25">{{ rightTexts }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		props: {
			// 左侧背景
			leftBg: {
				type: String,
				default: 'linear-gradient(to right, #ff9d6f, #f6544f)'
			},
			// 右侧背景
			rightBg: {
				type: String,
				default: 'linear-gradient(to right, #296bf0, #80d8fe)'
			},
			// 底色背景
			backBg: {
				type: String,
				default: '#edf2fb'
			},
			// 左侧长度
			leftNum: {
				type: Number,
				default: 0
			},
			// 右侧长度
			rightNum: {
				type: Number,
				default: 0
			},
			// 左侧文本
			leftText: {
				type: String,
				default: ''
			},
			// 右侧文本
			rightText: {
				type: String,
				default: ''
			}
		},
		computed: {
			leftTexts() {
				if(this.leftText) {
					return this.leftText
				} else {
					return this.leftNum + '%'
				}
			},
			rightTexts() {
				if(this.rightText) {
					return this.rightText
				} else {
					return this.rightNum + '%'
				}
			}
		},
		data() {
			return {}
		},
		methods: {
			
		}
	}
</script>

<style lang="scss">
.line_box{
	display: flex;
	.line_con{
		flex: 1;
		height: 40rpx;
		border-radius: 40rpx;
		display: flex;
		&.left{
			margin-right: 40rpx;
			justify-content: flex-end;
			.line{
				text-align: left;
			}
		}
		&.right{
			.line{
				text-align: right;
			}
		}
	}
	.line{
		border-radius: 40rpx;
		height: 100%;
	}
}
.txt{
	color: #fff;
	margin: 0 20rpx;
	&.left_out{
		color: #f55d59
	}
	&.right_out{
		color: #1d61ef
	}
}

.back{
	background: linear-gradient(#ff9d6f, #f6544f);
}
</style>

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值