濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > Html5百葉窗效果的示例代碼

Html5百葉窗效果的示例代碼

熱門(mén)標(biāo)簽:電銷(xiāo)機(jī)器人電話用什么卡 黃島區(qū)地圖標(biāo)注 云南大理400電話申請(qǐng)官方 四川點(diǎn)撥外呼系統(tǒng) 江蘇智能電銷(xiāo)機(jī)器人哪家好 鎮(zhèn)江智能外呼系統(tǒng)有效果嗎 成都智能外呼系統(tǒng)平臺(tái) 當(dāng)涂高德地圖標(biāo)注 南寧點(diǎn)撥外呼系統(tǒng)哪家公司做的好

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

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

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


 

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();
    //啟動(dòng)動(dòng)畫(huà)0.5s后,控制布局顯示/隱藏
    $timeout(function () {
             if ($scope.show) {
                  $scope.show = false;
              } else {
                    ....
              }
     }, 500);
 }
//啟動(dòng)動(dòng)畫(huà)
        $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);
        };

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

標(biāo)簽:南京 酒泉 十堰 淮安 西寧 佳木斯 廣西 咸寧

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Html5百葉窗效果的示例代碼》,本文關(guān)鍵詞  Html5,百葉窗,效果,的,示例,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Html5百葉窗效果的示例代碼》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于Html5百葉窗效果的示例代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    通化县| 基隆市| 灌阳县| 图片| 津南区| 安康市| 合水县| 武定县| 兴城市| 措勤县| 新巴尔虎右旗| 抚顺县| 慈利县| 喀什市| 上杭县| 易门县| 和平区| 和龙市| 光泽县| 莫力| 行唐县| 利津县| 沙坪坝区| 广安市| 乌兰县| 喀什市| 鹤山市| 宁蒗| 桃江县| 安图县| 屏边| 浦北县| 浙江省| 沧源| 邻水| 湖州市| 华池县| 营口市| 上虞市| 响水县| 广饶县|