
コーディングテクニックの実装内容
今回はカーテンアニメーションに関する内容です。画像の上に重ねた複数のカラーを連続でスライドさせてから画像を表示するカーテンアニメーションの実装方法を紹介します。
使いどころ
スクロールをして画像が見えたらアニメーションを実行させるのが一般的な使い方となります。
実装所要時間:10分程度
難易度:初心者コーダーでも実装可能
CSS,JavaScriptの記述内容
.block {
position: relative;
width: 768px;
line-height: 0;
margin: 50px auto 0;
}
.block .curtain {
position: absolute;
right: 0;
top: 0;
width: 100%;
height: 100%;
background: #dadada;
z-index: 1;
}
.block .curtain:before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 0;
height: 100%;
background: #e6a95d;
}
.block .curtain:after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 0;
height: 100%;
background: #dadada;
}
.block.active .curtain {
width: 0;
transition: width .7s ease-out .7s;
}
.block.active .curtain:before {
width: 100%;
transition: width .5s ease-out;
}
.block.active .curtain:after {
width: 100%;
transition: width .4s ease-out .4s;
}
@media screen and (max-width:640px){
.block {
width: 100%;
}
}
実装のポイント
現在制作中
スポンサーリンク