CSS文字條紋陰影動畫
阿新 • • 發佈:2019-02-20
今天給大家推薦個動畫條紋陰影效果,效果如下圖所示。
好的,讓我們開工吧,首先是so easy的html。
[html] view plaincopyprint?- <!--
- data-text屬性用來指定陰影內容
- -->
- <spanclass="shadow"data-text="Hello">Hello</span>
- /*
- with less hat & prefix free
-
only for webkit
- */
- /*匯入字型*/
- @import "http://fonts.googleapis.com/css?family=Dancing+Script:400,700";
- /*居中對齊的less mixin*/
- .center{
- position:absolute;
- top:50%;
- left:50%;
- .translate(-50%,-50%);
- }
然後我們進入正題。
[css] view plain- body{
- background-color:#27ae60;
- }
- .shadow{
- font-size: 12em;
- font-family: 'Dancing Script', cursive;
- color:#DC554F;
- .center;
- z-index:5;
- &:before{
- content:attr(data-text);
- position:absolute;
- top:6px;
- left:4px;
-
.opacity(.4
- background-image:
- linear-gradient(
- 45deg,
- transparent45%,
- hsla(48,20%,90%,1) 45%,
- hsla(48,20%,90%,1) 55%,
- transparent0
- );
- background-size: .05em .05em;
- .background-clip(text);
- /*Webkit Only,key code for the effect*/
- -webkit-text-fill-color: transparent;
- z-index:-1;
- animation: shadowGo 15s linear infinite;
- }
- }
- @keyframes shadowGo{
- 0% {background-position: 0 0}
- 0% {background-position: -100%100%}};