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;
	}
	}
相关推荐
AndrewMe82112 分钟前
detailed-docx:一个能保住格式的 Word 文档操作库
开发语言·python·word
IT方大同6 分钟前
RT_thread(RTOS实时操作系统)线程的创建与切换
c语言·开发语言·嵌入式硬件
智算菩萨11 分钟前
【OpenGL】6 真实感光照渲染实战:Phong模型、材质系统与PBR基础
开发语言·python·游戏引擎·游戏程序·pygame·材质·opengl
jinanwuhuaguo12 分钟前
OpenClaw深度沟通渠道-全景深度解构
大数据·开发语言·人工智能·openclaw
是翔仔呐13 分钟前
第14章 CAN总线通信全解:底层原理、帧结构与双机CAN通信实战
c语言·开发语言·stm32·单片机·嵌入式硬件·学习·gitee
我是伪码农23 分钟前
14届蓝桥杯
javascript·css·css3
客卿12326 分钟前
用两个栈实现队列
android·java·开发语言
leaves falling26 分钟前
C++模板初阶:让代码“复制粘贴”自动化
开发语言·c++·自动化
java1234_小锋39 分钟前
Java高频面试题:谈谈你对SpringBoot的理解?
java·开发语言·spring boot
2301_8166512239 分钟前
C++模块化设计原则
开发语言·c++·算法