ホームページ  >  記事  >  ウェブフロントエンド  >  HTML5 シャッター効果コード

HTML5 シャッター効果コード

不言
不言オリジナル
2018-07-03 11:53:053184ブラウズ

この記事では主に Html5 シャッターエフェクトのサンプルコードを紹介します。内容が非常に優れているので、参考として共有します。

この記事では、HTML5 ブラインド効果のサンプルコードを紹介し、皆さんと共有します。詳細は次のとおりです:

実装方法の紹介:

1. ブラインド レイアウトは、コンテンツをカバーするために位置決め (位置: 絶対) を使用します。レイアウト、背景は透明に設定されています (background-color: 透明)
2、キーフレームはフェードインとフェードアウト (透明度の変更) およびブラインド ウィンドウ効果アニメーションを定義します。
3. DOM の className 属性を設定してアニメーションを開始し、animator.className = 'baiyeWindow'; アニメーション完了イベント 'animationend' をリッスンし、className 属性をクリアします。
4. コンテンツ レイアウトの切り替えの場合は、起動アニメーション メソッドを呼び出します。両方のレイアウトで切り替えイベント ng-click="switchLayout()" をバインドする必要があります。


html コード:

<!--要显示百叶窗效果的布局--切换内容-->
<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>

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(&#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);
        };

以上が、皆様の学習のお役に立てば幸いです。関連コンテンツの PHP 中国語 Web サイトに注目してください。

関連する推奨事項:

HTML5キャンバスWeChatポスターについての紹介を共有

キャンバスでダイナミックなボールオーバーラップエフェクトコードを実現

以上がHTML5 シャッター効果コードの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。