강조강조 문구
이런 텍스트가 있다고 할 때, 강조 색상을 애니메이션 효과로 채우는 방법에 대한 글입니다.
<h1><strong data-text="안녕하십니까">안녕하십니까</strong> 환영합니다.</h1>
h1 {
color: #111;
}
h1 strong {
position: relative;
display: inline-block;
}
h1 strong::before,
h1 strong::after {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
display: inline-block;
width: 0;
height: 100%;
overflow: hidden;
white-space: pre;
word-break: normal;
transition: width 1s;
will-change: width;
}
h1 strong::before {
color: #fff;
-webkit-text-fill-color: #fff;
}
h1 strong::after {
color: red;
-webkit-text-fill-color: red;
z-index: 1;
}
h1 strong.fill::before,
h1 strong.fill::after {
width: 100%
}
$(function () {
setTimeout(function(){
$("h1 strong").addClass('fill');
},1000);
});