現在、ページの背景A・B・C・Dの4枚の画像をcssのanimationプロパティで入れ替えています。
また、その上に、a・b・c・dの異なるアニメーションをそれぞれのタイミング(Aの時にaが再生)でのせています(この部分も、もし自動的に連動させる方法があれば教えていただきたいです)。
アニメーションはループします。
具体的にしたいこと
・「Hello」という文字をクリックすると、ページ背景はAになり、かつ、aのアニメーションが再生される
・再生後は、b、c、d・・・とアニメーションが続く。
・「World」という文字をクリックすると、ページ背景はBになり、かつ、bのアニメーションが再生される
・再生後は、c、d、a・・・とアニメーションが続く。
・CとDも同じく、特定の文字をクリックすると、C背景&cのアニメーション・D背景&dのアニメーションが再生されればと思います。
現在のコード
html
1 <body> 2 <div class="page page002"> 3 <div class="bg"> 4 <ul><span>image01</span><div class="a"/></ul> 5 <ul><span>image02</span><div class="b"/></ul> 6 <ul><span>image03</span><div class="c"/></ul> 7 <ul><span>image04</span><div class="d"/></ul> 8</div> 9 <p> 10 <span id="word1">Hello</span><span id="word2">World</span> 11 </p> 12 </div> 13 </body>
css
1.bg ul span { 2 color: transparent; 3 width: 1024px; 4 height: 768px; 5 position: absolute; 6 top: 0px; 7 left: 0px; 8 background-size: cover; 9 background-repeat: none; 10 opacity: 0; 11 z-index: auto; 12 animation: imageAnimation 11000ms linear infinite 0ms; 13} 14 15.bg ul:nth-child(1) span { 16 background-image: url(../images/page/imageA.jpg) 17} 18.bg ul:nth-child(2) span { 19 background-image: url(../images/page/imageB.jpg); 20 animation-delay: 880ms; 21} 22.bg ul:nth-child(3) span { 23 background-image: url(../images/page/imageC.jpg); 24 animation-delay: 3500ms; 25} 26.bg ul:nth-child(4) span { 27 background-image: url(../images/page/imageD.jpg); 28 animation-delay: 6000ms; 29} 30.bg ul:nth-child(5) span { 31 background-image: url(../images/page/imageA.jpg); 32 animation-delay: 7800ms; 33}//4枚だとスタートに戻る時に表示がおかしくなってしまったため、5枚にしています 34 35@-webkit-keyframes imageAnimation { 36 0% { opacity: 0; -webkit-animation-timing-function: ease-in; } 37 8%{opacity: 1; -webkit-animation-timing-function: ease-out; } 38 25% {opacity: 1} 39 35% {opacity: 0} 40 100% {opacity: 0} 41} 42.no-cssanimations .bg ul span{ 43 opacity: 1; 44} 45.a{ 46 position: absolute; 47 width: 1024px; 48 height: 768px; 49 top: 0; 50 left: 0; 51 z-index: 3; 52 overflow: hidden; 53 background-image: url('../images/page/imagea.png'); 54 animation: a_anim 11000ms linear infinite; 55} 56 57@-webkit-keyframes a_anim { 58 0% {background-position: 0px 0px;opacity: 1} 59 0.001% { background-position:0px 0px;opacity: 1} 60 9.5%{background-position: 0px 1024px;opacity: 1} 61 10% {background-position: 0px 1024px;opacity: 0} 62 63 10% {;opacity:0} 64 100% { -webkit-transform: translate(0px, 0px);opacity: 0 } 65}//こんな感じのアニメーションがb・c・dとあります。bは全体の10〜40%で再生、cが40〜70%、dが残りです。
補足情報
コードの動作確認はsafariとchromeでおこなっています。
最終的にはepubファイルになる予定です。
jQueryライブラリは現在使っていませんが、必要であれば使用いたします。
回答1件
あなたの回答
tips
プレビュー