【uniapp】样式合集

1、修改uni-data-checkbox多选框的样式为单选框的样式

我原先是用的单选,但是单选并不支持选中后,再次点击取消选中;所以我改成了多选,然后改变多选样式,让他看起来像单选

在所在使用的页面上修改样式即可

html 复制代码
<uni-data-checkbox multiple selectedColor='#2979ff' selectedTextColor="#000" v-model="agree"
					:localdata="agreedata">
					<label>
						<checkbox />
						<view>我已阅读并同意
							<text class="col-g" @click="handleXI">《用户协议》</text>
							<text class="col-g" @click="handleYX">《隐私协议》</text>
						</view>
					</label>
				</uni-data-checkbox>
html 复制代码
<style lang="scss">
   //修改多选框的样式为单选样式
			.uni-data-checklist .checklist-group .checklist-box.is--default.is-checked .checkbox__inner .checkbox__inner-icon {
				opacity: 1;
				background-color: #2979ff !important;
			}

			.uni-data-checklist .checklist-group .checklist-box .checkbox__inner .checkbox__inner-icon {
				width: 8px !important;
				height: 8px !important;
				border-radius: 10px !important;

				top: 3px !important;
				left: 3px !important;
				height: 8px;
				width: 4px;
				border: 0px solid #2979ff !important;
			}

			.uni-data-checklist .checklist-group .checklist-box .checkbox__inner {
				border-radius: 8px !important;
				display: flex;
				flex-shrink: 0;
				box-sizing: border-box;
				justify-content: center;
				align-items: center;
				position: relative;
				width: 16px;
				height: 16px;
				border: 1px solid #DCDFE6;
				border-radius: 16px;
				background-color: #fff !important;
				z-index: 1;
			}
</style>

2、修改checkbox的样式

html 复制代码
<checkbox-group>
					<label style="display: flex;">
						<checkbox value="agree" class="checkbox" />
						<view>我已阅读并同意
							<text class="col-g" @click="handleYH">《用户协议》</text>及
							<text class="col-g" @click="handleYS">《隐私协议》</text>
						</view>
					</label>
				</checkbox-group>

样式必须得写在app.vue中

html 复制代码
.login_container {
		//自定义checkbox的样式( 元素使用的时候就是使用类名:checkbox )
		checkbox.checkbox .wx-checkbox-input,
		checkbox.checkbox .uni-checkbox-input {
			border-radius: 8px !important;
			display: flex;
			flex-shrink: 0;
			box-sizing: border-box;
			justify-content: center;
			align-items: center;
			position: relative;
			width: 16px;
			height: 16px;
			border: 1px solid #DCDFE6;
			border-radius: 16px;
			background-color: #fff !important;
			z-index: 1;
		}

		// 选中后的 对勾样式 
		checkbox.checkbox .uni-checkbox-input-checked::before,
		checkbox.checkbox .wx-checkbox-input-checked::before {
			width: 8px;
			height: 8px;
			border-radius: 10px !important;
			line-height: 20px;
			text-align: center;
			font-size: 18px;
			color: #fff;
			background: #2979ff;
			transform: translate(-70%, -50%) scale(1);
			-webkit-transform: translate(-70%, -50%) scale(1);
			position: absolute;
			top: 7px !important;
			left: 9px !important;
			border: 0px solid #2979ff !important;
		}
	}

3、uni-row的gutter无效

gutter的单位不是px是rpx,所以在设置的时候,要设置大一些

相关推荐
dy171717 小时前
vue左右栏布局可拖拽
前端·css·html
咬人喵喵18 小时前
告别无脑 <div>:HTML 语义化标签入门
前端·css·编辑器·html·svg
00后程序员张18 小时前
AppStoreInfo.plist 在苹果上架流程中的生成方式和作用
android·小程序·https·uni-app·iphone·webview
2501_9151063220 小时前
iOS App 测试方法,通过 Xcode、Instruments、Safari Inspector、克魔(KeyMob)等工具
android·ios·小程序·uni-app·iphone·xcode·safari
游戏开发爱好者820 小时前
对 iOS IPA 文件进行深度混淆的一种实现路径
android·ios·小程序·https·uni-app·iphone·webview
百锦再21 小时前
UniApp与UniApp X:跨平台开发的范式革命与全面技术解析
服务器·ai·uni-app·k8s·core·net
Change!!21 小时前
uniapp写的h5,怎么根据页面详情,设置不同的标题
前端·uni-app·标题
2501_9160074721 小时前
Xcode 在 iOS 上架中的定位,多工具组合
android·macos·ios·小程序·uni-app·iphone·xcode
浅箬21 小时前
uniapp 打包之后出现shadow-grey.png去除
前端·uni-app
游戏开发爱好者821 小时前
uni-app 项目在 iOS 上架过程中常见的问题与应对方式
android·ios·小程序·https·uni-app·iphone·webview