uniapp——列表选择样式

38 篇文章 2 订阅

案例

在这里插入图片描述

代码

<view class="list">
	<block v-for="(item,index) in 8" :key="index">
		<view class="item" @click="choosePackage(item)" :class="{'active':item == current}">
			<view class="i_money">
				<text class="i_num">2</text></view>
			<view class="i_txt">套餐</view>
		</view>
	</block>
</view>
export default {
	components: {},
	data() {
		return {
			current: 0,
		};
	},
	watch: {

	},
	onLoad() {

	},
	onShow() {

	},
	methods: {
		choosePackage(item) {
			console.log(item);
			this.current = item
		}
	}
}
.list {
	margin-top: 44rpx;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-gap: 16px 14px; //行间距 列间距
	
	.item {
		background: #FFFFFF;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		border: 1rpx solid #BCBCBC;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		padding: 20rpx 0;
	
		.i_money {
			font-weight: bold;
			font-size: 22rpx;
			color: #292929;
	
			.i_num {
				font-size: 30rpx;
			}
		}
	
		.i_txt {
			font-size: 22rpx;
			color: #292929;
			margin-top: 5rpx;
		}
	}
	
	.active {
		background: #FFFDFA;
		border: 1rpx solid #FE8300;
		position: relative;
	}
	
	.active::before {
		content: '';
		position: absolute;
		right: 5rpx;
		top: 6rpx;
		width: 12rpx;
		height: 9rpx;
		border-right: 2rpx solid #FFFFFF;
		border-top: 2rpx solid #FFFFFF;
		transform: rotate(135deg);
		z-index: 2;
	}
	
	.active::after {
		content: '';
		position: absolute;
		right: 0;
		top: 0;
		border-radius: 0 6rpx 0 10rpx;
		width: 26rpx;
		height: 26rpx;
		background-color: #FE8300;
	}
	}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值