
コーディングテクニックの実装内容
今回はボーダーアニメーションに関する内容です。テキストの下線(アンダーライン)を横方向に一周走らせるアニメーションを実装するテクニックを紹介します。
使いどころ
スクロールをしてテキストが見えたらアニメーションを実行させるのが一般的な使い方となります。
実装所要時間:10分程度
難易度:初心者コーダーでも実装可能
CSS,JavaScriptの記述内容
.wrap {
width: 768px;
margin: 0 auto;
text-align: center;
}
.text {
display: inline-block;
position: relative;
overflow: hidden;
margin: 200px auto 0;
padding: 0 0 20px;
font-size: 50px;
}
.text:before,.text:after {
position: absolute;
bottom: 0;
opacity: 0;
transform: translateX(-100%);
content: ' ';
display: block;
width: 100%;
height: 2px;
background: #000;
}
.active.text:before {
transition: 0.8s cubic-bezier(0.82, 0.01, 0.28, 0.99) 0.8s;
opacity: 1;
transform: translateX(110%);
}
.active.text:after {
transition: 1s cubic-bezier(0.82, 0.01, 0.28, 0.99) 1.2s;
opacity: 1;
transform: translateX(0%);
}
@media screen and (max-width:640px){
.wrap {
width: 100%;
}
}
実装のポイント
現在制作中
スポンサーリンク
「【CSS】テキストの下線(アンダーライン)を横方向に一周走らせるアニメーションを実装する方法」への1件のフィードバック
コメントは受け付けていません。