2017-05-29 14 views
0

次のようなテキストアニメーションがあります。しかし、アニメーション反復回数を全体のプロセスに適用することはできませんでした。私は最初からすべてのアニメーションを繰り返す必要があります。フレームにフレーム1から5 は、事前にありがとうすべてのアニメーションのCSSアニメーションの繰り返し

HTML:

<div class="sp-container"> 
     <div class="sp-content"> 

       <h2 class="frame-1">It's destroying the planet</h2> 

       <h2 class="frame-2">It's mass, mechanized murder</h2> 

       <h2 class="frame-3">You can stop it</h2> 

       <h2 class="frame-4">Now!</h2> 

       <h2 class="frame-5"><span>Save the planet.</span> <span>Love life.</span> <span>Go vegan.</span></h2> 


     </div> 
    </div> 

CSS: 。あなたは、次の1

広告要素があなたの親要素であり、すべてのアニメーションは、HTMLとすでに開始すべき .ad.animation .element{//animation defined here} のクラスの下で定義されている
<script> 
    // setting the element 
    element = document.getElementById("ad"); 
    // reset animation 
    setInterval(function() { 
    // -> delete class 
    element.classList.remove("animation"); 
    // -> triggering reflow /* The actual magic */ 
    // without this it wouldn't work. Try uncommenting the line and the transition won't be retriggered. 
    element.offsetWidth = element.offsetWidth; 
    // -> add the animation class so the animation is restarted 
    element.classList.add("animation"); 
    }, 7000); 
    // this is the timmer which sums up the total of animation time of elements and delays calculated by you 

</script> 

としてJSスクリプトを使用する必要があります

sp-container { 
    position:relative; 
    top: 30px; 
    left: 0px; 
    width: 100%; 
    height: 150px; 
    z-index: 0; 
    background: -webkit-radial-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3) 35%, rgba(0, 0, 0, 0.5)); 
    background: -moz-radial-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3) 35%, rgba(0, 0, 0, 0.5)); 
    background: -ms-radial-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3) 35%, rgba(0, 0, 0, 0.5)); 
    background: radial-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3) 35%, rgba(0, 0, 0, 0.5)); 

} 

.sp-content { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    left: 0px; 
    top: 0px; 
    z-index: 1000; 

} 

.sp-container h2 { 
    position: absolute; 
    top: 50%; 
    line-height: 100px; 
    height: 90px; 
    margin-top: -50px; 
    font-size: 70px; 
    width: 100%; 
    text-align: center; 
    color: transparent; 
    -webkit-animation: blurFadeInOut 3s ease-in backwards; 
    -moz-animation: blurFadeInOut 3s ease-in backwards; 
    -ms-animation: blurFadeInOut 3s ease-in backwards; 
    animation: blurFadeInOut 3s ease-in backwards; 





} 

.sp-container h2.frame-1 { 
    -webkit-animation-delay: 0s; 
    -moz-animation-delay: 0s; 
    -ms-animation-delay: 0s; 
    animation-delay: 0s; 

} 

.sp-container h2.frame-2 { 
    -webkit-animation-delay: 3s; 
    -moz-animation-delay: 3s; 
    -ms-animation-delay: 3s; 
    animation-delay: 3s; 
} 

.sp-container h2.frame-3 { 
    -webkit-animation-delay: 6s; 
    -moz-animation-delay: 6s; 
    -ms-animation-delay: 6s; 
    animation-delay: 6s; 
} 

.sp-container h2.frame-4 { 
    font-size: 150px; 
    -webkit-animation-delay: 9s; 
    -moz-animation-delay: 9s; 
    -ms-animation-delay: 9s; 
    animation-delay: 9s; 
} 

.sp-container h2.frame-5 { 
    -webkit-animation: none; 
    -moz-animation: none; 
    -ms-animation: none; 
    animation: none; 
    color: transparent; 
    text-shadow: 0px 0px 1px #fff; 

} 

.sp-container h2.frame-5 span { 
    -webkit-animation: blurFadeIn 3s ease-in 12s backwards; 
    -moz-animation: blurFadeIn 1s ease-in 12s backwards; 
    -ms-animation: blurFadeIn 3s ease-in 12s backwards; 
    animation: blurFadeIn 3s ease-in 12s backwards; 
    color: transparent; 
    text-shadow: 0px 0px 1px #fff; 
    animation-iteration-count:infinite; 
    -webkit-animation-iteration-count:infinite; 
} 

.sp-container h2.frame-5 span:nth-child(2) { 
    -webkit-animation-delay: 13s; 
    -moz-animation-delay: 13s; 
    -ms-animation-delay: 13s; 
    animation-delay: 13s; 
} 

.sp-container h2.frame-5 span:nth-child(3) { 
    -webkit-animation-delay: 14s; 
    -moz-animation-delay: 14s; 
    -ms-animation-delay: 14s; 
    animation-delay: 14s; 

} 






/**/ 

@-webkit-keyframes blurFadeInOut { 
    0% { 
    opacity: 0; 
    text-shadow: 0px 0px 40px #fff; 
    -webkit-transform: scale(1.3); 
    } 
    20%, 
    75% { 
    opacity: 1; 
    text-shadow: 0px 0px 1px #fff; 
    -webkit-transform: scale(1); 
    } 
    100% { 
    opacity: 0; 
    text-shadow: 0px 0px 50px #fff; 
    -webkit-transform: scale(0); 
    } 
} 

@-webkit-keyframes blurFadeIn { 
    0% { 
    opacity: 0; 
    text-shadow: 0px 0px 40px #fff; 
    -webkit-transform: scale(1.3); 
    } 
    50% { 
    opacity: 0.5; 
    text-shadow: 0px 0px 10px #fff; 
    -webkit-transform: scale(1.1); 
    } 
    100% { 
    opacity: 1; 
    text-shadow: 0px 0px 1px #fff; 
    -webkit-transform: scale(1); 
    } 
} 

@-webkit-keyframes fadeInBack { 
    0% { 
    opacity: 0; 
    -webkit-transform: scale(0); 
    } 
    50% { 
    opacity: 0.4; 
    -webkit-transform: scale(2); 
    } 
    100% { 
    opacity: 0.2; 
    -webkit-transform: scale(5); 
    } 
} 




/**/ 

@-moz-keyframes blurFadeInOut { 
    0% { 
    opacity: 0; 
    text-shadow: 0px 0px 40px #fff; 
    -moz-transform: scale(1.3); 
    } 
    20%, 
    75% { 
    opacity: 1; 
    text-shadow: 0px 0px 1px #fff; 
    -moz-transform: scale(1); 
    } 
    100% { 
    opacity: 0; 
    text-shadow: 0px 0px 50px #fff; 
    -moz-transform: scale(0); 
    } 
} 

@-moz-keyframes blurFadeIn { 
    0% { 
    opacity: 0; 
    text-shadow: 0px 0px 40px #fff; 
    -moz-transform: scale(1.3); 
    } 
    100% { 
    opacity: 1; 
    text-shadow: 0px 0px 1px #fff; 
    -moz-transform: scale(1); 
    } 
} 

@-moz-keyframes fadeInBack { 
    0% { 
    opacity: 0; 
    -moz-transform: scale(0); 
    } 
    50% { 
    opacity: 0.4; 
    -moz-transform: scale(2); 
    } 
    100% { 
    opacity: 0.2; 
    -moz-transform: scale(5); 
    } 
} 




/**/ 

@keyframes blurFadeInOut { 
    0% { 
    opacity: 0; 
    text-shadow: 0px 0px 40px #fff; 
    transform: scale(1.3); 
    } 
    20%, 
    75% { 
    opacity: 1; 
    text-shadow: 0px 0px 1px #fff; 
    transform: scale(1); 
    } 
    100% { 
    opacity: 0; 
    text-shadow: 0px 0px 50px #fff; 
    transform: scale(0); 
    } 
} 

@keyframes blurFadeIn { 
    0% { 
    opacity: 0; 
    text-shadow: 0px 0px 40px #fff; 
    transform: scale(1.3); 
    } 
    50% { 
    opacity: 0.5; 
    text-shadow: 0px 0px 10px #fff; 
    transform: scale(1.1); 
    } 
    100% { 
    opacity: 1; 
    text-shadow: 0px 0px 1px #fff; 
    transform: scale(1); 
    } 
} 

@keyframes fadeInBack { 
    0% { 
    opacity: 0; 
    transform: scale(0); 
    } 
    50% { 
    opacity: 0.4; 
    transform: scale(2); 
    } 
    100% { 
    opacity: 0.2; 
    transform: scale(5); 
    } 
} 
+0

あなたはアニメーション広告をしています。あなたが達成するのが難しいか不可能である同じ/完璧なタイミングを持つ場合にのみサイクルを繰り返すことはできません。最後のアニメーションが終了した後、JSを使用してアニメーションを再起動する必要があります。 –

+0

@DincaAdrianはあなたの努力のために大変ありがとうございます。残念ながら、私はJSを知らない:(あなたは助けてもらえますか?) –

答えて

2

主な要素は次のように定義されています:

<div onclick='window.location.href="http://www.google.com"' id="ad" class="ad animation"> 

ここでは、 t(カスタムまたはgoogleAds /その他の広告プロバイダ)、すぐにアニメーションを開始できます。 7000ミリ秒はアニメーションの合計時間を表し、それに応じて変更します。これが助けてほしいと願っています。D

+0

また、アニメーションで懇願している場合は、サイドノートとして、そのための良いライブラリはhttp://lesshat.madebysource.com/ですそれはあなたがより少なく学ぶ必要がありますが、2番目の問題で新しいアニメーションを定義することができるので生産性を大幅に向上させます)また、ブラウザの互換性を確保するための良いライブラリです。 –

+0

ありがとうしかし、私はこのクラスをどこで使うべきかわかりませんでした**。ad.animation .element {//ここで定義されたアニメーション} ** –

+0

すべてのアニメーションは* .animation *クラスの下で定義されます。 –

関連する問題