Home > Web Front-end > H5 Tutorial > body text

Html5 shutter effect code

不言
Release: 2018-07-03 11:53:05
Original
3219 people have browsed it

This article mainly introduces the sample code of Html5 blinds effect. The content is quite good. Now I will share it with you and give it as a reference.

This article introduces the sample code of the Html5 blinds effect and shares it with everyone. The details are as follows:

Introduction to the implementation method:

1, use positioning (position: absolute) for the blinds layout Covered on the content layout, the background is set to transparent (background-color: transparent)
2, keyframes define fade-in and fade-out (transparency change) and blind window effect animation.
3. Start the animation by setting the className attribute of the DOM, animator.className = 'baiyeWindow'; listen to the animation completion event 'animationend', and clear the className attribute.
4. In the event of content layout switching, call the startup animation method. Both layouts need to bind the switching event ng-click="switchLayout()"
5. Animation execution timing diagram:


html code:

<!--要显示百叶窗效果的布局--切换内容-->
<p id="fadeInOut" class="content"  ng-click="switchLayout()">
...
</p>
<!--百叶窗布局-->
 <ul id="baiyeWindow"  ng-click="switchLayout()">
       <li><p class="ye"></p></li>
        <li><p class="ye"></p></li>
        <li><p class="ye"></p></li>
        <li><p class="ye"></p></li>
  </ul>
Copy after login

css style code:

  //谈入谈出效果
 .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;
          }
        }
      }
Copy after login

JS code:

//切换布局
$scope.switchLayout = function(){
    ...
    $scope.startBaiYeWindow();
    //启动动画0.5s后,控制布局显示/隐藏
    $timeout(function () {
             if ($scope.show) {
                  $scope.show = false;
              } else {
                    ....
              }
     }, 500);
 }
//启动动画
        $scope.startBaiYeWindow = function () {
            var animator = document.getElementById(&#39;baiyeWindow&#39;);
            var animatorFadeInOut = document.getElementById(&#39;fadeInOut&#39;);
            animator.addEventListener(&#39;animationend&#39;, function () {
                animator.className = &#39;&#39;;
                animatorFadeInOut.className = &#39;content&#39;;
            });
            $timeout(function () {
                animator.className = &#39;baiyeWindow&#39;;
                animatorFadeInOut.className = &#39;content fade-animation&#39;;
            }, 0);
        };
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone’s study. More related content Please pay attention to PHP Chinese website!

Related recommendations:

About html5 canvas WeChat poster sharing introduction

Canvas achieves the effect code of dynamic ball overlapping

The above is the detailed content of Html5 shutter effect code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!