从左到右动画文本填充

编程入门 行业动态 更新时间:2024-10-27 00:26:31
本文介绍了从左到右动画文本填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用CSS为文字填充动画。

I wanted to animate a the text fill with CSS. The Text should be filled with color from left to right.

这是我的CSS:

.box-with-text { background-image: -webkit-linear-gradient(right, crimson 50%, white 50%); background-repeat: repeat; background-position: 0 0; background-size: 200% 100%; -webkit-text-fill-color: transparent; -webkit-background-clip: text; -webkit-animation: stripes normal forwards ease-in-out; animation: stripes 2s normal forwards ease-in-out; }

现在只有第一个字母填充颜色。

Now only the first letter is color-filled.

这里是小提琴

推荐答案

你还可以看看flex(对中的东西)和 mix-blend-mode 也可用于Firefox:

you may also take a look at flex (for centering things) and mix-blend-mode, so it can be avalaible also for Firefox:

.box-with-text { text-transform: uppercase; font: bold 26vmax/.8 Open Sans, Impact; background: black; display: table; color: white; mix-blend-mode: multiply } @-webkit-keyframes stripes { to { background-size:100% 100%; } } @keyframes stripes { to { background-size:100% 100%; } } html { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-box-align:center; -webkit-align-items:center; -ms-flex-align:center; align-items:center; height: 100%; background: black; } body { margin: auto; background: -webkit-linear-gradient( crimson , crimson) turquoise no-repeat 0 0; background: linear-gradient( crimson , crimson) turquoise no-repeat 0 0; background-size: 0 100%; -webkit-animation: stripes 2s linear infinite; animation: stripes 2s linear infinite; }

<div class="box-with-text"> Text </div>

codepen.io/gc-nomade/pen/XKNKzd

更多推荐

从左到右动画文本填充

本文发布于:2023-11-06 17:16:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564301.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   动画   左到右

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!