2016-12-15 9 views
0

私は初心者のデベロッパー(多分その下でも)だと言って始めましょう。自分自身についてよく説明しなければ謝ります。CSSを使ってディレイを使ってフェードインでフェードアウトする

私たちの製品に関するいくつかの顧客レビューを画面(FadeIn1、遅延、FadeOut1)、(FadeIn2、遅延、FadeOut2)などにスプラッシュ表示しようとしています。フェードインとフェードアウト私は個別に働くことができません。以下のコードは、それを消すだけです。私が間違っていることを教えてもらえますか?事前のおかげで...

/* keyframes that tell the start state and the end state of our object */ 
 
    
 
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; }} 
 
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; }} 
 
@keyframes fadeIn { from { opacity:0; } to { opacity:1; }} 
 

 
@-webkit-keyframes fadeOut { from { opacity:1; } to { opacity:0; }} 
 
@-moz-keyframes fadeOut { from { opacity:1; } to { opacity:0; }} 
 
@keyframes fadeOut { from { opacity:1; } to { opacity:0; }} 
 
    
 
.fade-in { 
 
\t opacity:0; /* make things invisible upon start */ 
 
\t -webkit-animation:fadeIn ease-in 1; /* call keyframe named fadeIn, use animattion ease-in and repeat it only 1 time */ 
 
\t -moz-animation:fadeIn ease-in 1; 
 
\t animation:fadeIn ease-in 1; 
 
\t 
 
\t -webkit-animation-fill-mode:forwards; /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 1)*/ 
 
\t -moz-animation-fill-mode:forwards; 
 
\t animation-fill-mode:forwards; 
 

 
    \t -webkit-animation-duration:1s; 
 
\t -moz-animation-duration:1s; 
 
\t animation-duration:1s; 
 
} 
 

 
.fade-out { 
 
\t opacity:1; /* make things visible upon start */ 
 
\t -webkit-animation:fadeOut ease-out 1; /* call keyframe named fadeOut, use animattion ease-out and repeat it only 1 time */ 
 
\t -moz-animation:fadeOut ease-out 1; 
 
\t animation:fadeOut ease-out 1; 
 
    
 
\t -webkit-animation-fill-mode:forwards; /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 0)*/ 
 
\t -moz-animation-fill-mode:forwards; 
 
\t animation-fill-mode:forwards; 
 
    
 
\t -webkit-animation-duration:1s; 
 
\t -moz-animation-duration:1s; 
 
\t animation-duration:1s; 
 
\t 
 
\t -webkit-animation-delay: 3s; 
 
\t -moz-animation-delay: 3s; 
 
\t animation-delay: 3s; 
 
} 
 
    
 
.fade-in.fade-out.one { 
 
-webkit-animation-delay: 0.7s; 
 
-moz-animation-delay: 0.7s; 
 
animation-delay: 0.7s; 
 
} 
 
    
 
.fade-in.fade-out.two { 
 
-webkit-animation-delay: 1.2s; 
 
-moz-animation-delay:1.2s; 
 
animation-delay: 1.2s; 
 
} 
 
    
 
.fade-in.fade-out.three { 
 
-webkit-animation-delay: 1.6s; 
 
-moz-animation-delay: 1.6s; 
 
animation-delay: 1.6s; 
 
} 
 
    
 
/*---basic box ---*/ 
 
.box{ 
 
width: 200px; 
 
height: 200px; 
 
position: relative; 
 
margin: 10px; 
 
float: left; 
 
border: 1px solid #333; 
 
background: #999; 
 
}
<body> 
 
<div class="box fade-in fade-out one"> 
 
     look at me fade in and out 
 
</div> 
 
    
 
<div class="box fade-in fade-out two"> 
 
     i can fade too! 
 
</div> 
 
    
 
<div class="box fade-in fade-out three"> 
 
     i can fade three! 
 
</div> 
 
    
 
</body>

答えて

0

あなたは%フレームの代わりにを使用してアニメーションを簡素化することができます。

.boxアニメーションセレクタの下で、アニメーションの速度を制御できます。

@-webkit-keyframes myfade { 
 
    0% { 
 
    opacity: 0 
 
    } 
 
    20% { 
 
    opacity: 0 
 
    } 
 
    30% { 
 
    opacity: 1 
 
    } 
 
    40% { 
 
    opacity: 1 
 
    } 
 
    50% { 
 
    opacity: 1 
 
    } 
 
    60% { 
 
    opacity: 1 
 
    } 
 
    70% { 
 
    opacity: 0 
 
    } 
 
    80% { 
 
    opacity: 0 
 
    } 
 
    100% { 
 
    opacity: 0 
 
    } 
 
} 
 
@-moz-keyframes myfade { 
 
    0% { 
 
    opacity: 0 
 
    } 
 
    20% { 
 
    opacity: 0 
 
    } 
 
    30% { 
 
    opacity: 1 
 
    } 
 
    40% { 
 
    opacity: 1 
 
    } 
 
    50% { 
 
    opacity: 1 
 
    } 
 
    60% { 
 
    opacity: 1 
 
    } 
 
    70% { 
 
    opacity: 0 
 
    } 
 
    80% { 
 
    opacity: 0 
 
    } 
 
    100% { 
 
    opacity: 0 
 
    } 
 
} 
 
@keyframes myfade { 
 
    0% { 
 
    opacity: 0 
 
    } 
 
    20% { 
 
    opacity: 0 
 
    } 
 
    30% { 
 
    opacity: 1 
 
    } 
 
    40% { 
 
    opacity: 1 
 
    } 
 
    50% { 
 
    opacity: 1 
 
    } 
 
    60% { 
 
    opacity: 1 
 
    } 
 
    70% { 
 
    opacity: 0 
 
    } 
 
    80% { 
 
    opacity: 0 
 
    } 
 
    100% { 
 
    opacity: 0 
 
    } 
 
} 
 
.box { 
 
    width: 200px; 
 
    height: 200px; 
 
    position: relative; 
 
    margin: 10px; 
 
    float: left; 
 
    border: 1px solid #333; 
 
    background: #999; 
 
    animation: myfade 8s; 
 
    opacity: 0 
 
}
<body> 
 
    <div class="box fade-in fade-out one"> 
 
    look at me fade in and out 
 
    </div> 
 
    <div class="box fade-in fade-out two"> 
 
    i can fade too! 
 
    </div> 
 
    <div class="box fade-in fade-out three"> 
 
    i can fade three! 
 
    </div> 
 
</body>

0

あなたの元のコードは非常に近いです。

@keyframes fade { 
 
    0% { opacity: 0 } 
 
    20% { opacity: 1 } /* 20% of 5 seconds = 1 second */ 
 
    80% { opacity: 1 } 
 
    100% { opacity: 0 } 
 
} 
 
    
 
.fade { 
 
    opacity:0; 
 
    animation: fade ease-in-out 5s; 
 
    animation-fill-mode: forwards; 
 
} 
 

 
.fade:nth-child(2) { animation-delay: 0.25s; } 
 
.fade:nth-child(3) { animation-delay: 0.5s; } 
 

 
.box{ 
 
    width: 100px; 
 
    height: 100px; 
 
    position: relative; 
 
    margin: 10px; 
 
    float: left; 
 
    border: 1px solid #333; 
 
    background: #999; 
 
}
<div class="box fade">Box 1</div> 
 
<div class="box fade">Box 2</div> 
 
<div class="box fade">Box 3</div>

:@ILoveCSSの解答とアニメーション遅延の使用時に構築、私は、これはあなたが探している効果だと思います
関連する問題