uniapp——列表选择样式

案例

代码

html 复制代码
<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>
javascript 复制代码
export default {
	components: {},
	data() {
		return {
			current: 0,
		};
	},
	watch: {

	},
	onLoad() {

	},
	onShow() {

	},
	methods: {
		choosePackage(item) {
			console.log(item);
			this.current = item
		}
	}
}
css 复制代码
.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;
	}
	}
相关推荐
名字还没想好☜1 分钟前
Next.js 中间件实战:鉴权、重定向与 A/B 分流
开发语言·前端·javascript·中间件·react·next.js
广州灵眸科技有限公司18 分钟前
瑞芯微RV1126B开发板(EASY-EAI-PI2) INI文件操作
java·前端·javascript·网络·人工智能
乐观勇敢坚强的老彭19 分钟前
C++浮点数使用注意事项
开发语言·c++
wuyk55528 分钟前
38.什么是C语言?从语法到工程落地的工程师视角解读
c语言·开发语言·stm32·单片机·mcu·51单片机
库克克31 分钟前
【C++ 】内联函数
java·开发语言·c++
zh_xuan36 分钟前
java 虚拟线程
java·开发语言·虚拟线程
心中有国也有家38 分钟前
AtomGit Flutter 鸿蒙客户端:ModalBottomSheet 实战
android·javascript·学习·flutter·华为·harmonyos
jason成都1 小时前
RTKLIB Java 移植踩坑复盘:卡尔曼滤波核心逻辑修复与滑坡场景实测验证
java·开发语言
一次旅行1 小时前
【AI工具】Rust-Based CLI:用 xargs 和并行加速你的 Linux 日常
linux·开发语言·rust
老毛肚1 小时前
juc线程通信
java·开发语言·jvm