微信小程序如何修改radio和checkbox的默認(rèn)樣式和圖標(biāo)
更新時(shí)間:2019年07月24日 11:22:57 作者:暗戀桃花源丫
這篇文章主要介紹了微信小程序修改radio和checkbox的默認(rèn)樣式和圖標(biāo),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
wxml:
<view class="body"> <view class="body-content"> 第1題:企業(yè)的價(jià)值觀是 ? </view> <view class="label">單選</view> </view> <view class="options"> <radio-group class="radio-group" bindchange="radioChange"> <label class="radio" wx:for="{{items}}" wx:key="{{index}}"> <view> <radio value="{{item.name}}" checked="{{item.checked}}"/>{{item.value}} </view> </label> </radio-group> </view>
我們看一下原生的效果:
修改wxml中的redio 組件的color屬性:
<radio value="{{item.name}}" checked="{{item.checked}}" color="#fff"/>{{item.value}}
wxss(只有修改樣式的部分):
/* 單選、多選 勾選 */ /*radio未選中時(shí)樣式 */ radio .wx-radio-input{ /* 自定義樣式.... */ /* 我這里沒有進(jìn)行,未選中的樣式修改 height: 40rpx; width: 40rpx; margin-top: -4rpx; border-radius: 50%; border: 2rpx solid #999; background: transparent; */ } /* 選中后的 背景樣式 (紅色背景 無邊框 可根據(jù)UI需求自己修改) */ radio .wx-radio-input.wx-radio-input-checked { /* border: none; */ border-color: #2792ff!important; /* background-color: #fff!important; */ /* background-color: transparent!important; */ /* 居中 */ /* display: flex; justify-content: center; align-items: center; */ } /* 選中后的 對勾樣式 (白色對勾 可根據(jù)UI需求自己修改) */ radio .wx-radio-input.wx-radio-input-checked::before { /* 去除對號 */ content: ''; /* background: #fff; */ width: 36rpx; height: 36rpx; border-radius: 50%; /* background: red; */ background-color: #2792ff; /* 居中 */ /* margin-top: 0rpx; */ /* display: flex; */ /* position: relative; */ }
修改后的單選框樣式:
復(fù)選框同理
wxml:
<view class="body"> <view class="body-content"> 第1題:企業(yè)的價(jià)值觀是 ? </view> <view class="label">多選</view> </view> <view class="options"> <checkbox-group bindchange="checkboxChange"> <label class="checkbox" wx:for="{{items}}"> <view> <checkbox value="{{item.name}}" checked="{{item.checked}}"/>{{item.value}} </view> </label> </checkbox-group> </view>
wxss:
/*checkbox未選中時(shí)樣式 */ checkbox .wx-checkbox-input{ /* 自定義樣式.... */ border-radius: 50%; } /* 選中后的 背景樣式 (紅色背景 無邊框 可根據(jù)UI需求自己修改) */ checkbox .wx-checkbox-input.wx-checkbox-input-checked { /* border: none; */ border-radius: 50%; border-color: #2792ff!important; } /* 選中后的 對勾樣式 (白色對勾 可根據(jù)UI需求自己修改) */ checkbox .wx-checkbox-input.wx-checkbox-input-checked::before { /* 去除對號 */ content: ''; /* background: #fff; */ width: 36rpx; height: 36rpx; border-radius: 50%; /* background: red; */ background-color: #2792ff; /* 居中 */ /* margin-top: 0rpx; */ /* display: flex; */ /* position: relative; */ }
修改前后對比:
前
后
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JS實(shí)現(xiàn)頁面長時(shí)間不操作退出到登錄頁面的示例代碼
這篇文章主要介紹了JS實(shí)現(xiàn)頁面長時(shí)間不操作退出到登錄頁面的示例代碼,通過在head標(biāo)簽中引入jquey和頁面長時(shí)間不操作的js頁面,結(jié)合實(shí)例代碼講解的非常詳細(xì),需要的朋友可以參考下2024-03-03JavaScript實(shí)現(xiàn)計(jì)算字符串中出現(xiàn)次數(shù)最多的字符和出現(xiàn)的次數(shù)
這篇文章主要介紹了JavaScript實(shí)現(xiàn)計(jì)算字符串中出現(xiàn)次數(shù)最多的字符和出現(xiàn)的次數(shù),本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-03-03plupload+artdialog實(shí)現(xiàn)多平臺(tái)上傳文件
這篇文章主要介紹了plupload+artdialog實(shí)現(xiàn)多平臺(tái)上傳文件的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07