【uniapp】小程序中使用css实现一个带框的加减号

  uni版完整代码如下:【网页用的话直接把css拉出去,写一个div即可】 注意:px->rpx我没改

<template>
	<view class="add"></view>
</template>


<script>

</script>

<style scoped>
	.add {
		border: 1px solid;
		width: 100px;
		height: 100px;
		color: #ccc;
		transition: color .25s;
		position: relative;
	}


	.add::before {
		content: '';
		position: absolute;
		left: 50%;
		top: 50%;
		width: 80px;
		margin-left: -40px;
		margin-top: -5px;
		border-top: 10px solid;
	}

	.add::after {
		content: '';
		position: absolute;
		left: 50%;
		top: 50%;
		height: 80px;
		margin-left: -5px;
		margin-top: -40px;
		border-left: 10px solid;
	}

	.add:hover {
		color: red;
	}
</style>

这个案例的有点大,我自己写了个44rpx x 44rpx的凑合用:

<template>
	<view class="add"></view>
</template>


<script>

</script>

<style scoped>
	.add {
		border: 1rpx solid;
		width: 44rpx;
		height: 44rpx;
		color: #D9D9D9;
		transition: color .25s;
		position: relative;
		margin-top: 80rpx;
		margin-left: 180rpx;
	}


	.add::before {
		content: '';
		position: absolute;
		left: 50%;
		top: 50%;
		width: 28rpx;
		margin-left: -13rpx;
		margin-top: 0rpx;
		border-top: 2rpx solid;
	}

	.add::after {
		content: '';
		position: absolute;
		left: 50%;
		top: 50%;
		height: 28rpx;
		margin-left: 0rpx;
		margin-top: -13rpx;
		border-left: 2rpx solid;
	}

	.add:hover {
		color: red;
	}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值