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

首頁 > 開發(fā) > HTML5 > 正文

Html5百葉窗效果的示例代碼

2024-09-05 07:22:15
字體:
供稿:網(wǎng)友

本文介紹了Html5百葉窗效果的示例代碼,分享給大家,具體如下:

實現(xiàn)方法介紹:

1,百葉窗布局 用定位(position: absolute)覆蓋在content布局之上,背景設(shè)置為透明(background-color: transparent)
2,keyframes定義淡入淡出(透明度改變)和百葉窗口效果動畫。
3,啟動動畫是通過設(shè)置DOM的className屬性的方法,animator.className = 'baiyeWindow'; 監(jiān)聽動畫完成事件'animationend',要清除className屬性。
4,在內(nèi)容布局切換的事件,調(diào)用啟動動畫方法,兩個布局都需要綁定切換事件 ng-click="switchLayout()"
5,動畫執(zhí)行時序圖:


 

html代碼:

<!--要顯示百葉窗效果的布局--切換內(nèi)容--><div id="fadeInOut" class="content"  ng-click="switchLayout()">...</div><!--百葉窗布局--> <ul id="baiyeWindow"  ng-click="switchLayout()">       <li><div class="ye"></div></li>        <li><div class="ye"></div></li>        <li><div class="ye"></div></li>        <li><div class="ye"></div></li>  </ul>

css樣式代碼:

  //談入談出效果 .fade-animation{        @-webkit-keyframes fadeInOut {          0% {            opacity: 1;          }          50% {            opacity: 0;          }          100% {            opacity: 1;          }        }    @keyframes fadeInOut {          0% {            opacity: 1;          }          50% {            opacity: 0;          }          100% {            opacity: 1;          }        }        animation: fadeInOut 1s ease-in;        -webkit-animation: fadeInOut 1s ease-in;      }      //百葉窗效果      .baiyeWindow{        width: 100%;        height: 1.68rem;        position: absolute;        left: 0;        top: 1.2rem;        li{          height: 0.42rem;          line-height: 40px;          overflow: hidden;          background-color: transparent;          .ye{            -webkit-animation: slideOut 1s ease-in-out;            animation: slideOut 1s ease-in-out;            width: 100%;            background-color: rgba(0,0,0,.2);            position: relative;            top: 50%;          }        }        @-webkit-keyframes slideOut {          0% {            padding-bottom: 0;            top: 50%;          }          100% {            padding-bottom: 40px;            top: 0;          }        }        @keyframes slideOut {          0% {            padding-bottom: 0;            top: 50%;          }          100% {            padding-bottom: 40px;            top: 0;          }        }      }

JS代碼:

//切換布局$scope.switchLayout = function(){    ...    $scope.startBaiYeWindow();    //啟動動畫0.5s后,控制布局顯示/隱藏    $timeout(function () {             if ($scope.show) {                  $scope.show = false;              } else {                    ....              }     }, 500); }//啟動動畫        $scope.startBaiYeWindow = function () {            var animator = document.getElementById('baiyeWindow');            var animatorFadeInOut = document.getElementById('fadeInOut');            animator.addEventListener('animationend', function () {                animator.className = '';                animatorFadeInOut.className = 'content';            });            $timeout(function () {                animator.className = 'baiyeWindow';                animatorFadeInOut.className = 'content fade-animation';            }, 0);        };

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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 苏尼特左旗| 吴旗县| 弥渡县| 新沂市| 南康市| 乌苏市| 九江县| 蓝山县| 永泰县| 临邑县| 东山县| 集安市| 英德市| 楚雄市| 长垣县| 贞丰县| 萍乡市| 嘉鱼县| 靖安县| 诸暨市| 客服| 广南县| 普格县| 内丘县| 西平县| 乳源| 措勤县| 襄垣县| 招远市| 靖江市| 鄂尔多斯市| 遂溪县| 逊克县| 盘山县| 德江县| 蓬安县| 嘉兴市| 讷河市| 田阳县| 新和县| 景宁|