最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2018年01月31日 08:41:00   作者:Rattenking  
這篇文章主要為大家詳細介紹了微信小程序switch組件的實現(xiàn)方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下

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

效果圖

switch組件實現(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">藍色switch組件---開</span> 
 <input class="fui-switch" style="color:blue" type="checkbox" checked>
</div>
<div class="switch-list">
 <span class="fui-fr">藍色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;}

實現(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è)計圖代表 100px ;
switch 的切換動畫是通過 CSS3 的 transition 屬性實現(xiàn);
主要是控制 switch 的 after 的移動,以及 before 的放大縮小動畫。

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

相關(guān)文章

最新評論

香港| 探索| 托克逊县| 彰武县| 邢台县| 海林市| 长丰县| 涡阳县| 大冶市| 诸城市| 辽中县| 凉山| 东乡县| 铅山县| 无极县| 昌吉市| 平顶山市| 江源县| 秦安县| 万年县| 永宁县| 华容县| 三江| 南部县| 张家川| 明溪县| 香格里拉县| 昭平县| 基隆市| 上饶县| 蒲城县| 肥西县| 获嘉县| 宣汉县| 五峰| 杨浦区| 方城县| 清涧县| 绥德县| 津南区| 高清|