微信小程序查看官方樣式及修改checkbox樣式為圓圈


小程序中checkbox的樣式是正方形的,設計圖上給的是一個圓圈,在查看官方demo的時候發現了怎么修改的

  1. 首先在微信官方文檔上找到復選框的demo

image-20200918164207698

  1. 然后審查代碼找到復選框的樣式部分

image-20200918164340190

可以看到選中的復選框的class為wx-checkout-input

image-20200918164459613

選中的樣式為wx-checkbox-input-checked

  1. 這樣我們就可以自己修改樣式了

先弄成圓圈:

	<checkbox class="interestthreecheckbox" value="{{item.id}}"/>
.interestthreecheckbox .wx-checkbox-input {
  border-radius: 50%;
  width: 35rpx;
  height: 35rpx;
}

image-20200918164809882

還可以設置選中的背景顏色

.interestthreecheckbox .wx-checkbox-input.wx-checkbox-input-checked{
  background: lightblue;
  border: 1px solid lightblue;
}

image-20200918165521580

也可以修改對勾的顏色大小

對勾默認的樣式:

wx-checkbox .wx-checkbox-input.wx-checkbox-input-checked:before {
    font: normal normal normal 14px/1 "weui";
    content: "\EA08";
    font-size: 22px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -48%) scale(0.73);
    -webkit-transform: translate(-50%, -48%) scale(0.73);

修改的樣式

.interestthreecheckbox .wx-checkbox-input.wx-checkbox-input-checked::before{
  width: 40rpx;/* 選中后對勾大小 */
  height: 40rpx;/* 選中后對勾大小 */
  font-size:80rpx; /* 對勾大小30rpx */
  color:blue; /* 對勾顏色 白色 */
}

image-20200918164941547


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM