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;
	}
	}
相关推荐
张元清11 分钟前
使用 Hooks 构建无障碍 React 组件
前端·javascript·面试
Yupureki22 分钟前
《Linux系统编程》12.基础IO
linux·运维·c语言·开发语言·数据库·c++
淮北49422 分钟前
bash下好用的快捷键以及linux常用指令
linux·开发语言·ubuntu·bash
薛定谔的猫喵喵41 分钟前
卸载 Python 3.8 报错 “Could not set file security” 的终极解决方案
开发语言·python
Mahut1 小时前
从零构建神经影像可视化库:neuroviz 的架构设计与实现
前端·javascript·github
奇怪的猫1 小时前
浏览器窗口最小化的时候,setInterval 执行变慢,解决方案
前端·javascript
看山是山_Lau1 小时前
代码命名规范原则与原理
c语言·开发语言
cmd1 小时前
别再混淆了!JS类型转换底层:valueOf vs toString vs Symbol.toPrimitive 详解
前端·javascript
_MyFavorite_1 小时前
JAVA重点基础、进阶知识及易错点总结(8)List 接口(ArrayList、LinkedList、Vector)
java·开发语言·list