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

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

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

本文實(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)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 獲取JAVASCRIPT時(shí)間戳函數(shù)的5種方法

    獲取JAVASCRIPT時(shí)間戳函數(shù)的5種方法

    JavaScript獲得時(shí)間戳的方法有五種,后四種都是通過實(shí)例化時(shí)間對(duì)象new?Date()?來進(jìn)一步獲取當(dāng)前的時(shí)間戳,JavaScript處理時(shí)間主要使用時(shí)間對(duì)象Date,本文對(duì)js時(shí)間戳函數(shù)獲取方法給大家介紹的非常詳細(xì),需要的朋友參考下吧
    2024-01-01
  • 微信小程序block的使用教程

    微信小程序block的使用教程

    這篇文章主要介紹了微信小程序block的使用 ,微信小程序最近非常火熱,實(shí)現(xiàn)起來也很簡單,只要block就可以實(shí)現(xiàn),需要的朋友可以參考下
    2018-04-04
  • javascript與CSS復(fù)習(xí)(三)

    javascript與CSS復(fù)習(xí)(三)

    呵呵,又弄成了三部曲,這是最后一部分,關(guān)于鼠標(biāo)和瀏覽器本身顯示上的一些屬性。
    2010-06-06
  • js實(shí)現(xiàn)簡單拼圖小游戲

    js實(shí)現(xiàn)簡單拼圖小游戲

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)簡單拼圖小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • JavaScript復(fù)制文案到剪貼板小技巧

    JavaScript復(fù)制文案到剪貼板小技巧

    這篇文章主要為大家介紹了JavaScript復(fù)制文案到剪貼板實(shí)現(xiàn)小技巧,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07
  • 淺析JS給原始數(shù)據(jù)類型加屬性和方法為什么不報(bào)錯(cuò)

    淺析JS給原始數(shù)據(jù)類型加屬性和方法為什么不報(bào)錯(cuò)

    這篇文章主要想和大家一起探討一下JavaScript中給原始數(shù)據(jù)類型添加屬性和方法為什么不報(bào)錯(cuò),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下
    2023-11-11
  • 使用js實(shí)現(xiàn)一個(gè)可編輯的select下拉列表

    使用js實(shí)現(xiàn)一個(gè)可編輯的select下拉列表

    這篇文章主要介紹了使用js實(shí)現(xiàn)一個(gè)可編輯的select下拉列表,個(gè)人感覺還不錯(cuò),需要的朋友可以參考下
    2014-02-02
  • JavaScript中輸出</script>標(biāo)簽的方法

    JavaScript中輸出</script>標(biāo)簽的方法

    這篇文章主要介紹了JavaScript中輸出</script>標(biāo)簽的方法,在一些廣告代碼中經(jīng)常會(huì)用到這個(gè)小技巧,需要的朋友可以參考下
    2014-08-08
  • JavaScript模擬實(shí)現(xiàn)新浪下拉菜單效果

    JavaScript模擬實(shí)現(xiàn)新浪下拉菜單效果

    這篇文章主要為大家介紹了如何通過JavaScript模擬實(shí)現(xiàn)新浪的下拉菜單效果,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以動(dòng)手試一試
    2022-03-03
  • 通過復(fù)制Table生成word和excel的javascript代碼

    通過復(fù)制Table生成word和excel的javascript代碼

    通過復(fù)制Table生成word和excel,個(gè)人感覺這個(gè)功能還是比較實(shí)用的,下面有個(gè)不錯(cuò)的示例,希望對(duì)大家有所幫助
    2014-01-01

最新評(píng)論

静安区| 宁化县| 体育| 赤壁市| 青川县| 隆昌县| 武鸣县| 桐柏县| 靖安县| 乾安县| 昆明市| 诸暨市| 香港| 永兴县| 黄山市| 金秀| 新田县| 南开区| 阳东县| 车险| 德保县| 武川县| 红河县| 泰顺县| 阿合奇县| 盐池县| 沛县| 谢通门县| 即墨市| 玉树县| 邯郸县| 新泰市| 岳阳县| 凭祥市| 曲松县| 贡觉县| 达拉特旗| 浏阳市| 济源市| 西林县| 巴南区|