国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

微信小程序switch組件使用詳解

2019-11-19 14:27:10
字體:
供稿:網(wǎng)友

本文實(shí)例為大家分享了微信小程序switch組件的實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下

效果圖

switch組件實(shí)現(xiàn)

HTML

<div class="switch-list"> <span class="fui-fr">紅色switch組件</span> <input class="fui-switch" style="color:rgb(255, 0, 0);" type="checkbox" checked></div><div class="switch-list"> <span class="fui-fr">綠色switch組件</span> <input class="fui-switch" style="color:rgb(76, 216, 100);" type="checkbox" checked></div><div class="switch-list"> <span class="fui-fr">綠色禁用switch組件</span> <input class="fui-switch" style="color:rgb(76, 216, 100);" type="checkbox" checked disabled></div><div class="switch-list"> <span class="fui-fr">藍(lán)色switch組件---開</span>  <input class="fui-switch" style="color:blue" type="checkbox" checked></div><div class="switch-list"> <span class="fui-fr">藍(lán)色switch組件---關(guān)</span>  <input class="fui-switch" style="color:blue" type="checkbox"></div>

CSS

.switch-list{ padding: .5rem;}.fui-switch{ position: relative; width: .87rem; height: .5rem; z-index: 10; display: inline-block; outline: medium; border: 1px solid #dfdfdf; border-radius: .25rem; background-color: #dfdfdf; -webkit-appearance: none; -moz-appearance: none; vertical-align: middle;}.fui-switch:checked{ border-color: currentColor; background-color: currentColor;}.fui-switch::after,.fui-switch::before{ content: ""; position: absolute; height: .44rem; top: 0; left: 0; border-radius: .25rem; -webkit-transition: -webkit-transform .3s; transition: -webkit-transform .3s; transition: transform .3s; transition: transform .3s,-webkit-transform .3s;}.fui-switch:before { width: .84rem; background-color: #fdfdfd;}.fui-switch:checked:before { -webkit-transform: scale(0); transform: scale(0);}.fui-switch:after { width: .44rem; background-color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4);}.fui-switch:checked:after { -webkit-transform: translateX(.4rem); transform: translateX(.4rem);}.fui-switch[disabled] { opacity: .5;}.fui-fr{font-size: .3rem;vertical-align: middle;}

實(shí)現(xiàn)rem的JS

(function(win,factory){ factory(win); window.addEventListener('resize',function(){factory(win)},false);}(window,function(win){ var width = document.documentElement.clientWidth; width = width > 750 ? 750 : width; document.documentElement.style.fontSize = width / 7.5 + 'px';}));

注意

此處 1rem 在 750 的 psd 設(shè)計(jì)圖代表 100px ;
switch 的切換動(dòng)畫是通過 CSS3 的 transition 屬性實(shí)現(xiàn);
主要是控制 switch 的 after 的移動(dòng),以及 before 的放大縮小動(dòng)畫。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 阿尔山市| 顺平县| 广河县| 临沂市| 昭苏县| 民县| 那坡县| 新平| 临城县| 江口县| 陇西县| 甘德县| 宁德市| 屏东县| 安康市| 永安市| 元谋县| 灯塔市| 洪泽县| 兴仁县| 阿克苏市| 襄樊市| 名山县| 郸城县| 从江县| 湘潭县| 西城区| 房产| 洛浦县| 马山县| 上栗县| 报价| 电白县| 新竹县| 泸州市| 栾川县| 云安县| 滁州市| 安福县| 兰溪市| 九江市|